Hello. I have a problem with my vehicle spawn GUI. When i press the vehicle i want it makes the vehicle spawn value true.
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Rp = game.ReplicatedStorage
local V4 = Rp.Vehicles.Enviro200
script.Parent.Veh4.MouseButton1Click:Connect(function()
script.Parent.Enviro200.Value = true
end)
As you can see the script makes the value true (which it does). Then in the Script i make an if statement and it does not work in server.
Player = game.Players.LocalPlayer
Character = Player.Character
Rp = game.ReplicatedStorage
V4 = Rp.Vehicles.Enviro200
while true do
wait(0.05)
if script.Parent.Enviro200.Value == true then
if Player.leaderstats.Money.Value >= 0 then
ClonedVehicle = V4:Clone()
ClonedVehicle.Parent = game.Workspace
ClonedVehicle.PrimaryPart = ClonedVehicle.Body.Main
ClonedVehicle:SetPrimaryPartCFrame(Character.Head.CFrame)
script.Parent.Visible = false
script.Parent.Enviro200.Value = false
else
script.Parent.Veh4.Text = "You don't have enough Money!"
wait(3)
script.Parent.Veh4.Text = "Enviro 200 - FREE!"
end
end
end
It works in studio but not in the server itself. Please can i have some help? Thanks.

1 comment
If you don't have an answer, use the comments please. Only answer if you have a solution to the person's problem.