Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my PushBack script won't push players?

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local human = hit.Parent:FindFirstChild("Humanoid")
		if human then
			hit.Parent.Torso.Velocity = script.Parent.CFrame.LookVector * 20
		end
	end
end)

It pushes only NPCs But when the tool touches player it does nothing

2 comments

1

Most likely because the player's avatar isn't R6, therefore "Torso" doesn't exist. I'd recommend changing "Torso" to "HumanoidRootPart" so it's compatible with all player avatars.

0

^ Yes. Definitely.

1 answer

✓ Accepted answer

Hello.

So, the possible problem on your script is that in your game, the players are using the R15 rig, and 'Torso' is not a valid member of a R15 character. If you want it to be compatible with both rigs, then your script should be the following:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local human = hit.Parent:FindFirstChild("Humanoid")
        if human then
			hit.Parent.HumanoidRootPart.Velocity = script.Parent.CFrame.LookVector * 20
        end
    end
end)

The HumanoidRootPart is a valid member for both of rig types. I recommend you do this change.

I hope this help you, Ziruken

1 comment

0

I think you might just store that code in a local script since always in my scripts it just doesnt work on server

This discussion is preserved as it was. New answers, comments, and votes are closed.