I am making a spleef game, but I have a model with over 500 parts using the same name. I am trying to make blocks become damaged and then destroyed, but I don't know how to pass a specific block through a remoteEvent so that it appears for everyone. Any sugestions?
So first you would want to get the specific part that you would like to send through the remote event. Like so
local part = game.Workspace:FindFirstChild('Part') --Switch to how you get your part!
The ends and some things might be wrong and that's because I'm typing in the textbox and I'm retarded enough to not know how to use a keyboard correctly and how ends work
Anyways, after you got the part, you're going to want to fire the event and set part
as a parameter for the remote event
local part = game.Workspace:FindFirstChild('Part') local event = game.ReplicatedStorage:WaitForChild('RemoteEvent') --Change to your remote event's location! event:FireServer(part) --This is where you would fire the event to either the server, or the client. Inputting `part` inside the parenthesis adds `part` as a parameter and you would be able to access the part inside the function/event on the other script!
So after you have fired the remote event, you need to head on over to the other script and where you make the event to listen to when the remote event has been fired, you need to set the parameters. Whenever you fire the server, the first parameter is ALWAYS the player. If you do not put the player, the first parameter you put will be used as the player. So for example, if I put event.OnServerEvent:Connect(function(part)
, part
will be treated as the player
.
local part = game.Workspace:FindFirstChild('Part') local event = game.ReplicatedStorage:WaitForChild('RemoteEvent') event.OnServerEvent:Connect(function(player, part) --This is going to be called once the event is fired part:Destroy() --Destroying the part end
That's basically everything, please accept my answer if I helped you out, and if you got any other questions, I'll be happy to help you in the community chat!