Scripts really getting on my nerves, wont damage, wont play animation

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)
3 Likes

What exactly is :

local fist = script.Parent.Parent

Also, you should check to see if the a Humanoid is even found :

if humanoid1 then

end

This way, the script won’t break trying to pass a humanoid it didn’t find.

Ye sorry “fist” is the tool. I could do that humanoid thing that it doesnt help what im trying to do

I tested in studio and everything works for me.


Maybe try waiting for the humanoid when setting the variable humanoid1?

local humanoid1 = hit.Parent:WaitForChild("Humanoid")

H_Ow Do_es It W_OrK FOR you!!!

I am so freaking confused

Ill try waitforchild, it didnt work

Im so confused how it works for you. What did you do? can you carefully explain what you did?

Is the name of the dummies Humanoid called Humanoid?

Yes it is. Is my studio just broken or somethin


My LocalScript (Inside the tool):

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)


Result:

Image from Gyazo

The animation is an Action.

But that isnt my script. I see your script works but what is wrong with my script and how do I fix it.

I created my own code, based on what you showed (It’s the same concept). Perhaps it’s something else causing your code not to work.

But could you use my exact code and see if it works.

It’s the samething, except I don’t have window1.

Also note: you’re firing the same RemoteEvent that is used to damage the humanoid with your window1.

Hit:FireServer(humanoid1)
Hit:FireServer(parts)

Maybe this is your problem?

That was not the issue (sadly)

Hey! :smiley:
Change the Local Script to a Normal Script. I am not too sure about why it’s not taking damage though.

Why would I change it into a normal script?

I suggest you try first and then ask questions if it doesn’t work. And a local script can not play a server animation.

I’ve got a potential solution.

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?

The reason why is that Ive already tried to play it on the server though it didnt work.