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

More Help With My Car Spawner Script?

Asked by
Scootakip 299 Moderation Voter
8 years ago

I know I might be getting annoying, but I still need help.

repeat wait() until game.Players.LocalPlayer.Character

local car1 = game.Lighting.Car
local car2 = game.Lighting.Car2
local car3 = game.Lighting.Car3
local car4 = game.Lighting.Car4

local character = game.Players.LocalPlayer.Character
local ifcar = game.Players.LocalPlayer.Car
local gui = script.Parent
local mycar = game.Players.LocalPlayer.MyCar
gui.Text = "Get Car"

local carchoose = script.Parent.Parent.CarChoose
local carchoose1 = script.Parent.Parent.CarChoose.Car1Choose
local carchoose2 = script.Parent.Parent.CarChoose.Car2Choose
local carchoose3 = script.Parent.Parent.CarChoose.Car3Choose
local carchoose4 = script.Parent.Parent.CarChoose.Car4Choose
carchoose.Visible = false

local destroy = script.Parent.Parent.Des


function mycar1()
carchoose.Visible = false
if ifcar.Value == 0 then
a = car1:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,0,10))
a.Name = game.Players.LocalPlayer.Name.. " Car"
ifcar.Value = 1 
carchoose.Visible = false
end
end



function mycar2()
carchoose.Visible = false
if ifcar.Value == 0 then
a = car2:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,0,20))
a.Name = game.Players.LocalPlayer.Name.. " Car"
ifcar.Value = 1
end
end


function mycar3()
carchoose.Visible = false
if ifcar.Value == 0 then
a = car3:clone()
a.Parent = game.Workspace
wait()
a:MakeJoints()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,0,20))
a.Name = game.Players.LocalPlayer.Name.. " Car"
ifcar.Value = 1
end
end

function mycar4()
carchoose.Visible = false
if ifcar.Value == 0 then
a = car4:clone()
a.Parent = game.Workspace
a:MakeJoints()
wait()
wait()
a:MoveTo(character.Torso.Position + Vector3.new(0,-10,20))
a.Name = game.Players.LocalPlayer.Name.. " Car"
ifcar.Value = 1
end
end


function descar()
    if ifcar.Value == 1 then
        ifcar.Value = 0
        a = game.Workspace[game.Players.LocalPlayer.Name.. " Car"]
        a:remove()
    end
end



function onClicked()
if carchoose.Visible == false then
    carchoose.Visible = true
elseif carchoose.Visible == true then
    carchoose.Visible = false
    end
end





script.Parent.MouseButton1Click:connect(onClicked)
carchoose1.MouseButton1Click:connect(mycar1)
carchoose2.MouseButton1Click:connect(mycar2)
carchoose3.MouseButton1Click:connect(mycar3)
carchoose4.MouseButton1Click:connect(mycar4)
destroy.MouseButton1Click:connect(descar)

I've been using this script and it works completely fine in Roblox Studio singleplayer. When I get to an online environment, the script still works fine itself, but the cars spawn in... weirdly. I know this isn't really a scripting question (maybe it has something to do with the scripting) but when I spawn in cars there is something weird with each of them (except for Car3).

Car 1 spawns in and creates some weird invisible model that it spawns on top of, then it roles off of it and falls to the ground and doesn't have all of its scripts working correctly.

Car 2 and Car 4 just don't have their scripts working at all, it just spawns in as if the game wasn't in session and it was frozen.

I'm not sure how to fix this, but some help with these would be much appreciated

Car1 is the blue Roblox car Car2 is the Roblox Jeep Car3 (isn't having any issues) Car4 is a Sedan from freemodels

Once again, any help with this would be extremely appreciated.

Answer this question