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
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
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
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)
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.