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

How To Prevent A Character Fling From Trucks?

Asked by 4 years ago
Edited 4 years ago

so the trucks are welded in scripts, they are also parented to the player and character. after I spawn my truck from a store I will attempt to enter it but it flings my character away over and over. if I move my character left and right without being in the vehicle the truck will turn and move left and right, this issue is similar to the old mining inc game I have not been able to solve. This 1st script is the shop script of how and where the truck spawns after purchasing in game to the player. ive tampered with this in a few geusses and found myself reverting back to default.

BaseParts = {} SecParts = {}

function Touched(Part) if Part.Parent:FindFirstChild("Humanoid") ~= nil then if game.Players:FindFirstChild(Part.Parent.Name) ~= nil then if game.Players:FindFirstChild(Part.Parent.Name).PlayerGui:FindFirstChild("Shopping") == nil then local NewVal = Instance.new("BoolValue") NewVal.Name = "Shopping" NewVal.Value = true NewVal.Parent = game.Players:FindFirstChild(Part.Parent.Name).PlayerGui

            local NewShop = game.ReplicatedStorage.ShopGui:clone()
            NewShop.Parent = game.Players:FindFirstChild(Part.Parent.Name).PlayerGui
        end
    end
end

end

function Shopping(Player,Val) if Val == false and Player.PlayerGui:FindFirstChild("Shopping") ~= nil then Player.PlayerGui.Shopping:Destroy() end end

function LookForParts(Model) local AllModel = Model:GetChildren() for A = 1,#AllModel do if AllModel[A]:IsA("BasePart") then if AllModel[A].BrickColor == BrickColor.new("Dark stone grey") then table.insert(BaseParts,AllModel[A]) elseif AllModel[A].BrickColor == BrickColor.new("Medium stone grey") then table.insert(SecParts,AllModel[A]) end elseif AllModel[A].ClassName == "Model" then LookForParts(AllModel[A]) end end end

function SpawnTruck(Player,TruckName,BaseColor,SecColor) if Player.Character:FindFirstChild("TruckVal") ~= nil then Player.Character.TruckVal.Value:Destroy() Player.Character.TruckVal:Destroy() end

local NewTruck = game.ReplicatedStorage.Trucks:FindFirstChild(TruckName):Clone()
NewTruck.Parent = Player.Character

BaseParts = {}
SecParts = {}
LookForParts(NewTruck)
if BaseColor ~= BrickColor.new("Deep blue") then
    for A = 1,#BaseParts do
        if BaseParts[A] then
            BaseParts[A].BrickColor = BaseColor
        end
    end
end
if SecColor ~= BrickColor.new("Deep blue") then
    for A = 1,#SecParts do
        if SecParts[A] then
            SecParts[A].BrickColor = SecColor
        end
    end
end

local NewTruckVal = Instance.new("ObjectValue")
NewTruckVal.Parent = Player.Character
NewTruckVal.Name = "TruckVal"
NewTruckVal.Value = NewTruck    

NewTruck.Script.Disabled = false
wait()
if TruckName == "Mammoth" then
    NewTruck:SetPrimaryPartCFrame(CFrame.new(script.Parent.MammothSpawn.Position)*CFrame.Angles(0,math.rad(180),0))
else
    NewTruck:SetPrimaryPartCFrame(CFrame.new(script.Parent.Spawns:FindFirstChild("Spawn"..script.Parent.SpawnInUse.Value).Position+Vector3.new(0,12,0))*CFrame.Angles(0,math.rad(180),0))
end

local Angle = math.rad(180)
NewTruck.Base.BodyGyro.cframe = CFrame.Angles(0,Angle,0)
Player.Character.UpperTorso.CFrame = CFrame.new(NewTruck.Driver.Position+Vector3.new(0,4,0))
script.Parent.SpawnInUse.Value = script.Parent.SpawnInUse.Value + 1
if script.Parent.SpawnInUse.Value > 4 then
    script.Parent.SpawnInUse.Value = 1
end

end

script.Parent.ShopButton.Touched:connect(Touched) Workspace.Shopping.OnServerEvent:connect(Shopping) Workspace.SpawnTruck.OnServerEvent:connect(SpawnTruck)

0
We need to see scripts OBenjOne 190 — 4y
0
give me a few and ill round some up zxthexgamexz -5 — 4y
0
im unsure why the page has them separated but ive psted the entire 1st script from the shop where the problem may be coming from zxthexgamexz -5 — 4y

Answer this question