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

This script is suppose to push the character back when you step on it, not working?

I made as script so where, when you jump on a the object that you're touching, it's suppose to fling the character who touched it back. but for some reason it's not working, nor is it outputting errors. Help!

Local Script

script.Parent.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("UpperTorso") then

		script.Parent.PushBack:FireServer(hit)

	end

end)

Server Script

    db = true
    
 script.Parent.PushBack.OnServerEvent:Connect(function(hit)
    
    if db then
    
        db = false
    
        local torso = hit.Parent.UpperTorso
    
        torso.Velocity = (torso.CFrame.lookVector) * -100
    
        wait(2)
    
        db = true

    end

end)



[

](https://gyazo.com/57e9c28f23aa7914662dace8f404c515)

4 comments

0

LocalScripts will not run in the Workspace.

0

@RobloxWhizYT Okay I fixed that, now it's outputting errors and it's talking about how torso is a nil value, even though my character is in R15 2.0 and has an UpperTorso...

0

Try checking for the HumanoidRootPart instead of the UpperTorso.

0

On the server Script on line three do "script.Parent.PushBack.OnServerEvent:Connect(function(Player,hit)" That player is always supposed to be there

1 answer

Turns out I didn't even have to use a Remote Event, Server and Local Script at all. All I needed was a regular script and I just used BodyVelocity instead of Torso.

local debris = game:GetService("Debris")
db = false
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("UpperTorso") then
        if not db then
            db = true
            local torso = hit.Parent.UpperTorso
            local bv = Instance.new("BodyVelocity",torso)
       bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
       bv.Velocity = torso.CFrame.lookVector * -500
       debris:AddItem(bv,0.5)
            wait(2)
            db = false
        end
        
    end
end)

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