local plr = script.Parent.Parent local chr = plr.Character local deb = false --ChecksForTaggerBoolIsTrue while true do wait() if plr.Tagger == true then chr.Torso.Touched:connect(function(hit) if deb == false then deb = true if hit:FindFirstChild("Humanoid") then hit.Parent.Torso.Anchored = true end wait(2) deb = false end end) break end end
The Local Script is placed in the starterGUI so every player can obtain it when the join, but for some reason its not working. The Bools are working but this isnt and there isnt an error.
Ok, well there's one thing that you can try. Instead of finding the player by going through the parents, try doing this:
Player=game.Players.LocalPlayer --(LocalPlayer can only be used with LocalScripts)
This ensures that the script will not lose the player it's tracking if it's moved around.
Now, for the rest of it:
local plr = game.Players.LocalPlayer --:D local chr = plr.Character local deb = false while true do wait() if plr.Tagger.Value == true then chr.Torso.Touched:connect(function(hit) if deb == false then deb = true if hit.Parent:FindFirstChild("Humanoid") then --Added .Parent after hit hit.Parent.Torso.Anchored = true end wait(2) deb = false end end) end end
Try this. It should work now. I only changed a few things that you forgot to add in. Hope I helped :P
You referenced "hit" when you should've referenced "hit.Parent" to find the Humanoid on line 10, and the script can be done more efficiently. I also disconnected the touched event in the torso once tag becomes false. You can learn more about disconnecting events here.
Finished Script:
local player = game.Players.LocalPlayer local character = player.Character local debounce = false player.Tagger.Changed:connect(function(value) if value == true then tag = character.Torso.Touched:connect(function(hit) if not debounce and hit.Parent:FindFirstChild("Humanoid") then debounce = true hit.parent.Torso.Anchored = true wait(2) debounce = false end end) else tag:disconnect() end end)