My push script is not working

I’m making a push script and the script does not do anything to the player
I tried it with my friends and nothing worked.
how can I fix it?
heres the script:

  local input = game:GetService("UserInputService") 
local anim
local ph = script.Parent.Humanoid
local dmg = false
local d = true
local char = script.Parent
local anim
debounce = os.clock(0.5)


input.InputBegan:Connect(function(key) 
	local f = key.KeyCode
	if f == Enum.KeyCode.E then
		print("F")
		if d then
			anim = script.Parent.Humanoid:LoadAnimation(script.Animation):Play()
		end
	end
	local lArm = char:FindFirstChild("Left Arm")
	local torso = char:FindFirstChild("Torso")
	local a1 = Instance.new("Attachment")
	local a2 = Instance.new("Attachment")
	a1.Parent = lArm
	a2.Parent = torso
	lArm.Touched:Connect(function(hit)
		local h = hit.Parent:WaitForChild("Humanoid")
			if h then
				h:ChangeState(Enum.HumanoidStateType.Ragdoll)  
		end
	end)
end)

Edit: Im making the player ragdoll with the roblox ragdoll state type

1 Like

(I Made some edits now it should be more understandable)

can you show us the error output? would be easy

It doesn’t print any errors maybe i wrote something wrong

maybe show the whole script, there must be something else that causes that

edit: btw you should use game processed event (2nd argument of inputbegan and inputended services) so it doesnt accidentally happen while typing or naming a billboardtext ingame

thats the thing, I don’t know how remote event works or how to even use it in the script

its like sending a variable only local scripts can inherit from a localscript to a server script which allows it to use it without any errors vice versa

i tried doing it and it didnt work out well
but i tried it with another script which is similiar

what did you try to use with remote server? it’s important to learn it and know how to use it.

show an example of what u tried to do with it

also you should add some velocity power to the pushed user so they wont just slip to the ground when you touch them

btw if that animation isnt yours and you didnt upload it, it will not work since you have to use yours or just not add that line at all

“only if it says animation failed to load in the error output”

oh and if the user is r15 you should change the torso variable to humanoidrootpart and the arm make a if statement if the player is either r6 or r15.

local anim
local h = script.Parent.Humanoid
local dmg = false
local d = true
local char = script.Parent
local canPunch = false
local anim
debounce = os.clock(0.5)
local remote = script.Parent.RemoteEvent
local p = game.Players.LocalPlayer
local lArm = char:FindFirstChild("Left Arm")
local torso = char:FindFirstChild("Torso")

input.InputBegan:Connect(function(key) 
	local f = key.KeyCode
	if f == Enum.KeyCode.E then
remote.OnServerEvent:Connect(function(p)
	print("F")
	if d then
		canPunch = true
		d = false
		dmg = true
		anim = script.Parent.Humanoid:LoadAnimation(script.Animation):Play()
		wait(0.5)
		dmg = false
		d = true
		wait(2)
		canPunch = false
	end
end)
lArm.Touched:Connect(function(hit)
	if dmg then
		local h = hit.Parent:FindFirstChildOfClass("Humanoid")
		if h then
			h:TakeDamage(20)
			dmg = false
		end
	end
end)
end
end)

is there a local script firing the server event?

also you should read the dev hub to know the info of remote event, here is the link

Nope a regular script is running it

wait, this is the real problem, replace it with findfirstchild, not waitforchild
@nomcell

there is no wait for child in the script

no no the original script you sent

both of the script are wrong, in the remote event it’s right but the improper use of remote event made it not work, in the regular script you made it so it would wait for the humanoid.

which line was it in, i can’t find it

the line where you touch the person with your left arm

whats the number of the line I cant find the wait for child thing