I have the following script in a players "Events" that play localy depending on the players actions:
script:WaitForChild("Hide_Under_Bed").OnClientEvent:connect(function(BedObject) if BedObject then print(BedObject.Focus.Position) --Print an object's position in that model. else print("Y you do dis") end end)
And also this script in the object:
script.Parent.MouseClick:connect(function(player) repeat wait() until player.Character player.Character:WaitForChild("Events"):WaitForChild("Main"):WaitForChild("Hide_Under_Bed"):FireClient(script.Parent.Parent) end)
Here I want to pass the object value to the player's event as a parametrer so I don't have to write "game.Workspace...". I would do it, but I have multiple of these with the same name so roblox would not know which one is the correct one.
I don't know if that even is possible or not. If it is it would be nice to give me some guidance here on how to pass it correctly without getting the "attempting to index.." error, if not any idea on how to get the object I want with the same name as many others.
If confused let's say I have 10 Models called "Table" in workspace. But I want to get a ESPECIFIC table from those 10 without calling it's name because roblox would not know which one it is. That's basically it
You forgot to add something in your second script. :FireClient() has a first argument that requires the player to know which player it will fire to.
Line 3 should be something like this :
player.Character:WaitForChild("Events"):WaitForChild("Main"):WaitForChild("Hide_Under_Bed"):FireClient(player, script.Parent.Parent)
You'll notice at the end of the line, I added the parameter "player" from the function. This will fire the remote event specifically to the "player" and it should send whatever "script.Parent.Parent" is.
Hoped this helped!
--server script local Parent = script.Parent.Parent script.Parent.MouseClick:connect(function(player) -- // variables local Events = player.Character:WaitForChild('Events') local Main = Events:WaitForChild('Main') local HideEvent = Main:WaitForChild('Hide_Under_Bed') -- // fire event repeat wait() until player.Character HideEvent:FireClient(Parent) end)