I DON’T UNDERSTAND WHAT THE ISSUE IS ahhhhhhhhhhhhhhhh.
Ive been trying to fix this for the past couple of days and this tool punch script wont even work! There are no errors in the output, both scripts are in the tool’s handle, 1 is local the other is server and there is a remote event in replicated storage.
“fist” is the tool btw
No damage is dealt and no animation plays!!!
Please help! And please don’t just show me the script edited, tell me whats wrong and how to fix it.
Wait is my studio broken or something
local script:
local fist = script.Parent.Parent
local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local server = game.ReplicatedStorage
local Hit = server.Punch
local animator = humanoid:WaitForChild("Animator")
local animation = script.Parent.Animation
local Punch = animator:LoadAnimation(animation)
function onActivation()
Punch:Play()
fist.Handle.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
local PlayerWhoGotHit = game.Players:GetPlayerFromCharacter(hit.Parent)
Hit:FireServer(humanoid1)
end
end)
--Ignore this part of the code, it isnt implemented in teh server script
fist.Handle.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Window') then
local window1 = hit.Parent:FindFirstChild('Window')
local parts = {
window1:FindFirstChild("Weld 1"),
window1:FindFirstChild("Weld 2"),
window1:FindFirstChild("Weld 3"),
window1:FindFirstChild("Weld 4"),
window1:FindFirstChild("Weld 5"),
window1:FindFirstChild("Weld 6"),
}
Hit:FireServer(parts)
end
end)
end
--end of code not being used
fist.Activated:Connect(onActivation)
Server Script:
local storage = game.ReplicatedStorage
local punch = storage.Punch
local function onActivation(Player1, humanoid1)
humanoid1:TakeDamage(2)
end
punch.OnServerEvent:Connect(onActivation)
local Event = game:GetService("ReplicatedStorage"):WaitForChild("Attack")
local Player = game:GetService("Players").LocalPlayer
local humanoid = Player.Character:WaitForChild("Humanoid")
local Animator = humanoid :WaitForChild("Animator")
local Animation = Instance.new("Animation", script)
Animation.AnimationId = "rbxassetid://MYANIMATIONIDHERE"
Animation = Animator:LoadAnimation(Animation)
function onActivation()
print("Activated")
Animation:Play(0, 1, 2)
script.Parent.Handle.Touched:Connect(function(hit)
if (hit.Parent:FindFirstChild('Humanoid')) then
Event:FireServer(hit.Parent:FindFirstChild('Humanoid'))
end
end)
end
script.Parent.Activated:Connect(onActivation)
My ServerScript (Inside the tool):
local RemoteEv = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))
RemoteEv.Name = "Attack"
RemoteEv.OnServerEvent:Connect(function(player, humanoid)
if (humanoid == nil) then return end
humanoid:TakeDamage(2)
end)
Replace the variable humanoid in your local script with this:
local fist = script.Parent.Parent
local player = game.Players.LocalPlayer
-- Character defined with Player.Character VVV
local humanoid = Player.Character:WaitForChild("Humanoid") -- Replace with this
If the animation is being played inside the client’s character, it will replicate to the server.
@trueblockhead101, I’ve tried your exact code and it works for me. It may be an issue with the fist’s hitbox; have you tried making a print statement after the touch connection with fist.Handle and seeing if it runs?