HI idk why but my code only works on studio but when I play tested with my friends
it has so much bugs like only u can see when u damage someone not the player you hit and when you die the other player doesn’t see that u respawn and you don’t even see that you die at the first place(btw i’m a begginer and don’t know that much)
heres the code if you know why than pls tell me thx:
(sorry my code is so messy)
local player = game:GetService(“Players”).LocalPlayer
local mouse = player:GetMouse()
local puching = false
local key = game:GetService(“UserInputService”)
mouse.Button1Down:Connect(function()
** if puching == false then**
** puching = true**
** plaModle = game.Workspace:FindFirstChild(player.Name)**
** humanoid = game.Workspace:FindFirstChild(player.Name).Humanoid**
** anim = script:FindFirstChild(“Animation”)**
** loadanim = humanoid:LoadAnimation(anim)**
** loadanim:Play()**
** humanoid.WalkSpeed = 2**
** humanoid.JumpPower = 2**
** task.wait(0.8)**
** humanoid.WalkSpeed = 25**
** humanoid.JumpPower = 13.5**
** task.wait(0.7)**
** hit2 = false**
** plaModle.RightHand.Touched:Connect(function(hit)**
** if hit.Parent.Humanoid and hit2 == false and puching == true then**
** hit.Parent.Humanoid.Health -= 10**
** hit2 = true**
** task.wait(0.9)**
** hit2 = false**
** end**
** end)**
puching = false
** end**
end)
cooldown = false
local midAtk = false
local hit3 = false
key.InputBegan:Connect(function(input, g)
** if input.UserInputType == Enum.UserInputType.Keyboard then**
** if input.KeyCode == Enum.KeyCode.E and cooldown == false then**
** anim1 = script:FindFirstChild(“Animation1”)**
** loadanim1 = humanoid:LoadAnimation(anim1)**
** cooldown = true**
** loadanim1:Play()**
** midAtk = true**
** local legs = plaModle.RightFoot or plaModle.LeftFoot**
** if midAtk == true then**
** task.wait(0.2)**
** l = legs.Touched:Connect(function(hit)**
** l:Disconnect()**
** if hit.Parent.Humanoid and hit3 == false and midAtk == true then**
** hit3 = true**
** hit.Parent.Humanoid.Health -= 30**
** task.wait(5)**
** hit3 = false**
** midAtk = false **
** end**
** end)**
** end**
** cooldownlol()**
** task.wait(10)**
** cooldown = false**
** end**
** end**
** local uicooldown = game.StarterGui.ScreenGui.cooldown1**
** function cooldownlol()**
** local event = game.ReplicatedStorage.RemoteEvent**
** event:FireServer()**
** end**
end)
(btw I put this in game.StaterPlayer.PlayerScripts)