Server can't see remote event created by localscript

Basically I’m trying to make a plane, that, when sat in, creates a remote event named after the user who sat in it (I don’t know how else to prevent the user from controlling multiple planes on accident, so if someone helps me with that it would nullify the issue I’m having now.). The problem is, even though the remote event is placed in ReplicatedStorage, the server is never able to see it.

Server Script

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	print("Detected change in seat.")
	if(seat.Occupant ~= nil) then -- When the player sits in the vehicle:
		print("copying local script now")
		local newls = ls:Clone()
		--print(controls)
		newls.Parent = seat.Occupant.Parent --the local script being copied contains code to create the remote event.
		print("waiting on remote event now!")
		wait(2)
		controls = storage:WaitForChild(seat.Occupant.Parent.Name,20)
		print(controls)

Local Script

local storage = game:GetService("ReplicatedStorage")
local plr = game:GetService("Players").LocalPlayer
local controls = Instance.new("RemoteEvent") --storage:WaitForChild("controls")
controls.Name = plr.Name
controls.Parent = storage
print("created remote event!")

Dont create RemoteEvents in a local script. Youre only creating it on the client

Anything made with a Local Script or on the Client the Server is unable to see.

I am not understanding the issue, because the seat has the Occupant property which allows you to see who is in it. (The Property has the Character’s Humanoid)

I am just confused on how the Player would be able to control multiple planes?
If they were in a different plane the Occupant would be nil or another player for the last one.

2 Likes

This applies to everything made by a local script unless its information is fired to the server somehow

Think of it like this

A local script is only for you and your computer

A regular script is for everyone

1 Like

Yeah but I thought the point of replicated storage was that client and server could communicate.

Only when the remote event is created on the server, or you already have one in ReplicatedStorage when the game starts.

2 Likes

I just have to go back through my code, not sure how but when i get in one plane, it controls two at the same time. I don’t know why I didn’t really consider the occupant property… been looking at the code for too long. Thanks

you could probably make a server script like this

game.Players.PlayerAdded:Connect(function(player)
     local event = Instance.new('RemoteEvent', game.ReplicatedStorage)
     event.Name = tostring(player.Name..'SeatedEvent')
end

game.Players.PlayerRemoving:Connect(function(player)
     game.ReplicatedStorage:FindFirstChild(player.Name..'SeatedEvent'):Destroy()
end

And then do whatever with that lol

Edits: typos and a player removing thing

1 Like

I solved it by adding a check to see if the occupant property matched the player firing server events. Thanks all!

1 Like