Zootopia
|
  |
| Joined: 29 Apr 2009 |
| Total Posts: 1383 |
|
|
| 05 Jul 2014 10:14 PM |
I rewrote some badge givers so that they give the player the badge when they're clicked, instead of the default function of being touched. But it isn't working, so I must have written something wrong or didn't change an important function.
print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)
function onClicked(part) if (part.Parent:FindFirstChild("Humanoid") ~= nil) then local p = game.Players:GetPlayerFromCharacter(part.Parent) if (p ~= nil) then print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId) local b = game:GetService("BadgeService") b:AwardBadge(p.userId, script.Parent.BadgeID.Value) end end end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)
|
|
|
| Report Abuse |
|
|
Zootopia
|
  |
| Joined: 29 Apr 2009 |
| Total Posts: 1383 |
|
|
| 05 Jul 2014 10:15 PM |
| I suspect that it has something to do with the touched function, since touch functions allow scripts to easier identify the player to award, but I can't find anything in the script that would distinguish input from touching or clicking. |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2014 10:16 PM |
script.Parent.ClickDetector.MouseClick:connect(onClicked)
You wrote OnClicked which isn't the name of the function. |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2014 10:17 PM |
Also, in ClickDetectors, it returns the player not the character.
function onClicked(p) print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId) local b = game:GetService("BadgeService") b:AwardBadge(p.userId, script.Parent.BadgeID.Value) end |
|
|
| Report Abuse |
|
|