Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

one way door script works in roblox studios but not roblox game engine, really bad for my game?

Asked by 6 years ago

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

0
Is your game R15? You use "Torso", and sometimes Studio uses R6 unless you tell it otherwise. Use "LowerTorso" if your game's R15 SuperMario9595 150 — 6y
0
thanks, my game is R15 and i will fix that imaginevreything -50 — 6y
0
update: it worked! thanks so much! imaginevreything -50 — 6y

1 answer

Log in to vote
0
Answered by
xEmmalyx 285 Moderation Voter
6 years ago

Your game might be r15 or player's choice so a fix that would allow for both would be

01function onTouch(hit)
02if hit.Parent == nil then
03return end
04local h = hit.Parent:FindFirstChild("Humanoid")
05if h ~= nil then
06if hit.Parent:FindFirstChild("LowerTorso") then
07hit.Parent.LowerTorso.Velocity=door.CFrame.lookVector * 100
08else
09hit.Parent.Torso.Velocity = door.CFrame.lookVector * 100
10end
11end
12end
13door.Touched:connect(onTouch)

or you could just push the humanoidrootpart which is in both r15 and r6 models

1function onTouch(hit)
2if hit.Parent == nil then
3return end
4local h = hit.Parent:FindFirstChild("Humanoid")
5if h ~= nil then
6hit.Parent.HumanoidRootPart.Velocity = door.CFrame.lookVector * 100
7end
8end
9door.Touched:connect(onTouch)
Ad

Answer this question