Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

Player points are being awarded more than once?

Asked by 10 years ago

HELP! I'm trying to get my badges to award player points and they do - except they award it more than once despite a debounce and a check to see if the player has the badge?

Can anyone help? MD

ALSO: Is there anyway to test that this is working without getting other users without the badges to test it?


local awarded = false function OnTouch(part) if (part.Parent:FindFirstChild("Humanoid") ~= nil) then local p = game.Players:GetPlayerFromCharacter(part.Parent) if (p ~= nil) then if not awarded then awarded = true if game:GetService("BadgeService"):UserHasBadge(p.userId, 108424740) then print("Badge already awarded, no Player Points or Badge was given out") wait(2) awarded = false else print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId) local b = game:GetService("BadgeService") b:AwardBadge(p.userId, script.Parent.BadgeID.Value) p.PlayerGui.PlayerPoints.Frame.Label.Text = "You just earned 5 Player Points" if game.PointsService:GetAwardablePoints() >= 1 then game.PointsService:AwardPoints(p.userId,5) awarded = false p.PlayerGui.PlayerPoints.Frame.Visible = true p.PlayerGui.PlayerPoints.Frame:TweenPosition(UDim2.new(0.2, 0, 0, 0), "In") wait(5) p.PlayerGui.PlayerPoints.Frame:TweenPosition(UDim2.new(0.2, 0, -0.2, 0), "Out") end end end end end end script.Parent.Touched:connect(OnTouch)
0
You already had a reply via roblox.com/forum. systematicaddict 295 — 10y
0
Also, why are you setting awarded to false at line 13? systematicaddict 295 — 10y
0
I didn't expect one to be honest. Thought I'd post here with a new part to the question and with the better code formatting MasterDaniel 320 — 10y
0
I was using a debounce as was shown to me here: http://wiki.roblox.com/index.php?title=Debounce MasterDaniel 320 — 10y

Answer this question