So I have this code here
script.Parent.Touched:Connect(function(plr) local humanoidcheck = plr.Parent:FindFirstChild("Humanoid") if (humanoidcheck) then local player = game.Players:GetPlayerFromCharacter(humanoidcheck.Parent); if (player) then local orbfolder = player.orbfolder if orbfolder.orb1.Value == 0 then local orbs = player.leaderstats.Orbs orbs.Value = orbs.Value + 1 orbfolder.orb1.Value = 1 end end end end)
Its all fine and dandy till the
if orbfolder.orb1.Value == 0 then
section where this if statement seems to only check once. I've tested this in studio setting it to 1 and it still gives it, and then after this i set it to zero and it doesnt award it. Im not sure whats going on here, any help is appreciated!
If statements are supposed to only check something once. If you are trying to make it constantly check while player is touching, do something like this:
local touching script.Parent.Touched:Connect(function(plr) touching = true local humanoidcheck = plr.Parent:FindFirstChild("Humanoid") if (humanoidcheck) then local player = game.Players:GetPlayerFromCharacter(humanoidcheck.Parent); if (player) then local orbfolder = player.orbfolder while touching == false do if orbfolder.orb1.Value == 0 then local orbs = player.leaderstats.Orbs orbs.Value = orbs.Value + 1 orbfolder.orb1.Value = 1 end end end end end) part.TouchEnded:Connect(function(plr) touching = false
I would also recommend lining everything up to make it neater and easier to read. If you have any errors just comment on here!