This script is meant to make the player fly back when they are hit by this part, I tested it on a test game then put it into my main game but for some reason when it’s in the main game it doesn’t work, and I can’t figure out why.
script.Parent.Touched:Connect(function(h)
local speed = 400
local force = 80000
local kb = Instance.new("BodyVelocity")
kb.Parent = h.Parent:FindFirstChild("HumanoidRootPart")
kb.MaxForce = Vector3.new(force,force,force)
kb.Velocity = script.Parent.Parent:FindFirstChild("HumanoidRootPart").CFrame.LookVector * speed
wait(0.1)
kb.MaxForce = Vector3.new(0,0,0)
end)
Hey I was looking at ur script and I think the problem is that u are getting humanod root part as a parent and u arent totally sure if the parent of hit is a player. What if u hit baseplate? U are getting nil and then an error which will cause the script to break