Whats supposed to happen is you click a button, it fires an event to the server which will then open the doors on the right hand side.
When I click the button it says "TCP isn't a valid member of Player"
eventScript:
function OpenDoor(door,num) local left = door.Left:GetChildren() for n=1, #left do if left[n].ClassName == "Part" then left[n].Mesh.Offset = Vector3.new(-0.1*num, 0, 0) if num == 36 then left[n].CanCollide = false end end end local right = door.Right:GetChildren() for b=1, #right do if right[b].ClassName == "Part" then right[b].Mesh.Offset = Vector3.new(0.1*num, 0, 0) if num == 36 then right[b].CanCollide = false end end end end script.openRightDoors.OnServerEvent:connect(function(TrainVal) if TrainVal.TCP.Dir.Value == false then for a=1, 36 do OpenDoor(TrainVal.Car1.Door3,a) OpenDoor(TrainVal.Car1.Door4,a) OpenDoor(TrainVal.Car2.Door3,a) OpenDoor(TrainVal.Car2.Door4,a) wait(.01) end else for a=1, 36 do OpenDoor(TrainVal.Car1.Door1,a) OpenDoor(TrainVal.Car1.Door2,a) OpenDoor(TrainVal.Car2.Door1,a) OpenDoor(TrainVal.Car2.Door2,a) wait(.01) end
Button:
TrainVal = script.Parent.Parent.Parent.Train.Value function onClick() game.Workspace.traineventScript.openRightDoors:FireServer(TrainVal) end script.Parent.MouseButton1Click:connect(onClick)
OnServerEvent passes the player that the request came from automatically as the first argument since Roblox knows who the request came from, it can only be from that one player.
This will mean that 'TrainVal' holds the player note the error 'TCP is not a valid member of player'. To resolve this all we need to do is include another argument which will then hold the player.
Example:-
script.openRightDoors.OnServerEvent:connect(function(plr, TrainVal) print(plr, TrainVal) -- note i do not know what TrainVal is end)
I hope this helps.