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

Why does my slap tool damage script only work in-studio but not in-game?

Asked by 6 years ago
Player = game.Players.LocalPlayer
Character = Player.Character
local rightArm = Character['Right Arm']
local debounce = false

rightArm.Touched:Connect(function(Hit)
        Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(50)
            if not debounce and Hit.Parent:FindFirstChild("Humanoid").Health <= 0 then
                debounce = true
                Player.leaderstats.Kills.Value = Player.leaderstats.Kills.Value + 1
                wait(1)
                debounce = false

        end
    end)

There's my code, for some reason the rightArm portion conflicts with something so that the code doesn't run in-game.

0
Changes made to the humanoid's health locally will not be replicated to the server, meaning that you cant set the health of a character locally nor change the value of a value object. Use Remote Events/Functions to handle this for you. LifeInDevelopment 364 — 6y
0
So, use RemoteEvents to trigger another script that will damage the health of a character publicly? captaintbc 0 — 6y
0
Yes, make sure that the other script is a server script. Also you should be changing your leaderstat value objects in the server script as well. LifeInDevelopment 364 — 6y
0
Got it. captaintbc 0 — 6y

Answer this question