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

Help With Some Annoying Issue?

Asked by
Scootakip 299 Moderation Voter
8 years ago

After working on something for days I'm extremely frustrated to find out that this doesn't work In Multiplayer

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
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 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)

In the output it says that CarChoose is not a valid member of the Screen GUI when it is. All the gui in this is pre-created in starter gui. I'm extremely frustrated by this and would like some help with this.

1 answer

Log in to vote
0
Answered by 8 years ago

Add this to the very top

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

Answer this question