The goal is to prevent a character from leaving a car they are put into. My idea is to prevent the player from jumping. Is this the best method? if not what is? My Scripts: Script A
local noJump = script.NoJump:Clone() script.NoJump:Destroy() function CharacterSpawned(char) local noJ = noJump:Clone() noJ.Parent = char Delay(0.2, function() noJ.Disabled = false end) end function PlayerEntered(player) player.CharacterAdded:connect(CharacterSpawned) end for _,v in pairs(game.Players:GetPlayers()) do PlayerEntered(v) end game.Players.PlayerAdded:connect(PlayerEntered)
Script B(Inside A, Local Script)
local h = script.Parent:WaitForChild("Humanoid") h.Changed:connect(function() h.Jump = false end)
THANKS!
TheDeadlyPanther was on the right track with disabling the player from controlling the character. Luckily you are able to completely disable player control and still allow them to drive a vehicle. The best way (to my knowledge) to remove player control is by disabling the ControlScript in PlayerScripts. Here's some functions to disable/enable players ability to exit the vehicle.
function disableControl(player) if player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("ControlScript") then --Checks if there's a ControlScript to disable player.PlayerScripts.ControlScript.Disabled=true end end function enableControl(player) if player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("ControlScript") then --Checks if there's a ControlScript to enable player.PlayerScripts.ControlScript.Disabled=false end end
I would do one of these two: