generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Badge Giver Rewrite Help

Previous Thread :: Next Thread 
Zootopia is not online. 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 is not online. 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
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
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
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image