here is the script that I need help with:
door = script.Parent
function onTouch(hit) if hit.Parent == nil then return end local h = hit.Parent:FindFirstChild("Humanoid") if h ~= nil then hit.Parent.Torso.Velocity=door.CFrame.lookVector * 100 -- Push the Player back end end door.Touched:connect(onTouch)
this is a one way door and it only works in roblox studio but not roblox game engine when I test play it in roblox studios it works just fine but opon publishing it, it dose not work
Your game might be r15 or player's choice so a fix that would allow for both would be
01 | function onTouch(hit) |
02 | if hit.Parent = = nil then |
03 | return end |
04 | local h = hit.Parent:FindFirstChild( "Humanoid" ) |
05 | if h ~ = nil then |
06 | if hit.Parent:FindFirstChild( "LowerTorso" ) then |
07 | hit.Parent.LowerTorso.Velocity = door.CFrame.lookVector * 100 |
08 | else |
09 | hit.Parent.Torso.Velocity = door.CFrame.lookVector * 100 |
10 | end |
11 | end |
12 | end |
13 | door.Touched:connect(onTouch) |
or you could just push the humanoidrootpart which is in both r15 and r6 models
1 | function onTouch(hit) |
2 | if hit.Parent = = nil then |
3 | return end |
4 | local h = hit.Parent:FindFirstChild( "Humanoid" ) |
5 | if h ~ = nil then |
6 | hit.Parent.HumanoidRootPart.Velocity = door.CFrame.lookVector * 100 |
7 | end |
8 | end |
9 | door.Touched:connect(onTouch) |