Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why wont this script work for each player?

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

2 comments

0

Try changing the RemoteEvent's parent to ReplicatedStorage, it might be a problem with the client not being able to acess the object

0

k

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.