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

why wont this script work for each player?

Asked by
Benqazx 108
8 years ago
game.Players.PlayerAdded:connect(function(p)
local event = Instance.new("RemoteEvent") 
event.Parent = p
event.Name = "MyServerEvent" 
event.OnServerEvent:connect(function(player)
    local human = player.Character:FindFirstChild("Humanoid")
    local model = player.PlayerGui:FindFirstChild("VehicleGui").Model.Value
    local car = player.PlayerGui:FindFirstChild("VehicleGui").Car.Value
    if human:FindFirstChild(model) ~= nil then
        print("Human Found!")
        if human:FindFirstChild(model):FindFirstChild(car) ~= nil then
            print("Car Found!")
            local body = human:FindFirstChild(model):FindFirstChild(car):GetChildren()
            for i,v in pairs (body) do
                if v.Name == "Seat" then
                    v.Disabled = true
                    player.PlayerGui:FindFirstChild("VehicleGui").Open.Visible = true
                    player.PlayerGui:FindFirstChild("VehicleGui").Lock.Visible = false
                    print("Done!")
                end
            end
        end
    end
end)
end)

the remove even works on roblox single player studio and when i do 2 player roblox studio it only works for the server not for the players. so the Seat is disabled on the server but not for the players. why? please help this code is in a server script. the code that fires this is local script

0
Try changing the RemoteEvent's parent to ReplicatedStorage, it might be a problem with the client not being able to acess the object BlackJPI 2658 — 8y
0
k Benqazx 108 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Here's what I would do. I would make a script, disable it, and put into server storage and copy all of the code from line 5 to line 25 and add it to the script. Then when the player joins, copy the script and put it into the player. Then using the main script put the event parent as the script after making it. You would have to change line 5 to script.event.OnServerEvent. Finally, enable the script and it should work for every player.

Ad

Answer this question