I have attempted to fix it myself by putting it into a server script and testing outside of studio but im stumped currently.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()


debounce = false
enabled = true
Mouse.Button1Down:Connect(function()
	local enabled = true
	local character = Player.Character
	local hitbox = character:FindFirstChild("RightHand")
	local humanoid = character:FindFirstChild("Humanoid")
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://2701542598"
	local animation2 = Instance.new("Animation")
	animation2.AnimationId = "rbxassetid://2701542598"
	local animation3 = Instance.new("Animation")
	animation3.AnimationId = "rbxassetid://2701542598"
	local animpick = math.random(1,3)
	if animpick == 1 then
		local animTrack = humanoid:LoadAnimation(animation)
	animTrack:Play()
	enabled = false
	wait(3)
	enabled = true
	elseif animpick == 2 then
		local animTrack = humanoid:LoadAnimation(animation2)
		animTrack:Play()
		enabled = false
	wait(3)
	enabled = true
	elseif animpick == 3 then
		local animTrack = humanoid:LoadAnimation(animation3)
			enabled = false
	
		
		end
		
	
	hitbox.Touched:Connect(function(hit)
		if hit.Parent == character:FindFirstChild("RightHand") then
			
			
		
		else
			
			local humanoid = hit.Parent:FindFirstChild("Humanoid")
			if humanoid and enabled == true then
		enabled = false
			humanoid.Health = humanoid.Health - Player.leaderstats.Power.Value
			Player.leaderstats.Power.Value = Player.leaderstats.Power.Value + 1
			wait(1)
			enabled = true
			
			elseif humanoid == false and enabled == true then
				enabled = false
			Player.leaderstats.Power.Value = Player.leaderstats.Power.Value + 1
		
		wait(1)
		enabled = true
			
			
			
	

			end
			
		end
		end)
	
	end)

What the code is supposed to do is have the character run an animation and see if the right hand hits anything if it hit a humanoid it does damage. It seems to work on the surface but when i test it with multiple players it only changes anything on that players screen. Even if i kill someone they only appear dead on my screen vice versa.

The code is in a local script in StarterGui I would greatly appreciate for someone to help find the errors in the script

3 comments

1

Changing properties such as the humanoid's health on a localscript will only affect the client due to filtering enabled. You sould use Remote Events/Functions to go about this: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

0

alright thank you

0

it fixed the issue thank you very much