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

How Do I Force a player to sit in a VehicleSeat and make them not be able to leave?

Asked by
RM0d 305 Moderation Voter
9 years ago
function module:CarSpawn(player,Pos,par)
    wait()
    local car
    local val = player:WaitForChild("Values")
        local kt = val:WaitForChild("KartChosen")

        repeat wait() until (carModels:FindFirstChild(val.KartChosen.Value)) 
     car = carModels:FindFirstChild(val.KartChosen.Value):Clone()

        --anchor(car,true,true,"VehicleSeat")   
    local center = car:GetModelCFrame() 
    TransformObjects(car:GetChildren(),center,Pos +Vector3.new(0, (car:GetExtentsSize().Y /2) + 1,0),true)  

    car:MakeJoints() wait() 

    repeat wait() until player.Character
    repeat wait() until player.Character.Torso


    player.Character.Humanoid.WalkSpeed = 0
     car.Parent=par car:MakeJoints()
    Instance.new("Model",car).Name = "DestoryOnLeave"
    --player.Character.Torso.CFrame = car.VehicleSeat.CFrame + Vector3.new(0,car:GetExtentsSize().Y  + 1 ,0)

    local Xeld = Instance.new("Weld",car.VehicleSeat) -- makes a weld 
    Xeld.Name = "SeatWeld"
    Xeld.Part0,Xeld.Part1  = Xeld.Parent,   player.Character.HumanoidRootPart -- welds the parts
    player.Character.Humanoid.Sit = true -- makes the player sit
    Xeld.C0,Xeld.C1 = CFrame.new(   0, 0.6, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0),CFrame.new(0, -1.5, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0)
    --Aujust the positions.




   return car

end 

Thats the code, All works as expected aparting from welding the player to the seat.

    local Xeld = Instance.new("Weld",car.VehicleSeat) -- makes a weld 
    Xeld.Name = "SeatWeld"
    Xeld.Part0,Xeld.Part1  = Xeld.Parent,   player.Character.HumanoidRootPart -- welds the parts
    player.Character.Humanoid.Sit = true -- makes the player sit
    Xeld.C0,Xeld.C1 = CFrame.new(   0, 0.6, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0),CFrame.new(0, -1.5, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0)
    --Aujust the positions

The exact code "sniped" that dose not work as expected.

Any question feel free to ask though pm on roblox or comment below, Username : DarkBeemo

0
It's worth noting that GetModelCFrame() is deprecated, you should use MoveTo() instead. http://wiki.roblox.com/index.php?title=API:Class/Model/MoveTo ChipioIndustries 454 — 9y

1 answer

Log in to vote
2
Answered by
SirGory 15
9 years ago

I would use a script to position the Character with 0 Speed and a No-Jump feature

player.Character.Humanoid.WalkSpeed=0
player.Character.Humanoid.Jumping:connect(function()
player.Character.Humanoid.Jump=false
end)
player.Character.Torso.CFrame=car.VehicleSeat.CFrame+Vector3.new(0,3,0)

Although I don't think this is the best way to do it

0
no but sometimes the player dosen't get tped into the seat sometimes like 60% chance, Thanks for your help tho. RM0d 305 — 9y
1
Im testing your method now (Again, Also its WalkSpeed not Speed) RM0d 305 — 9y
0
Yeah, sorry SirGory 15 — 9y
0
Its alright, it might work. RM0d 305 — 9y
0
it worked other some mess around, it still followed your concept. RM0d 305 — 9y
Ad

Answer this question