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

Vehicle Spawn Not Working For Vehicles in server??

Asked by 6 years ago

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 answer

Log in to vote
0
Answered by
DevNetx 250 Moderation Voter
6 years ago

Regular scripts cannot access game.Players.LocalPlayer. You'll need to find the player in a different way.

0
If you don't have an answer, use the comments please. Only answer if you have a solution to the person's problem. KingLoneCat 2642 — 6y
Ad

Answer this question