This local script is stored in the workspace, parent to the part.
The remote event is also stored in ReplicatedStorage
Running the script would show no error and according to my understanding the player consists of the player’s name that triggered the prompt.
local IDPP = game:GetService("ReplicatedStorage"):WaitForChild("ID Printer")
IDPP.OnClientEvent:Connect(function(player)
print("hi")
local printer = game.Workspace["ID Printer"]
printer:FindFirstChild("ID Printer Prompt"):Destroy()
end)
I tried running print() command in the local script to check if it even connects, but it did not work. Am I missing something?
I manage to make the script work by placing the local script into StarterPlayer.StarterPlayerScripts but I am unsure if there are any flaws in doing so.
If you are talking about the Local Script, it would not connect. Else if you are referring to the Server Script it will be destroyed for other players too, which is not my goal to do so.
The parent of localscript has to be in the service StarterCharacterScripts or StarterPlayerScripts.
I recommend you to pass the object as an argument which after modifying the script, it should look like this
In this way, there won’t be any error in finding ID Printer in the above line that you’ve written in localscript
local printer = game.Workspace["ID Printer"]
After making the necessary changes by passing the argument, your localscript ( Parented to the service StarterCharacterScripts or StarterPlayerScripts) should look like this
local IDPP = game:GetService("ReplicatedStorage"):WaitForChild("ID Printer")
IDPP.OnClientEvent:Connect(function(script.Parent)
print("hi")
script.Parent:Destroy()
end)
The parents of localscript should always be the service StarterCharacterScripts or StarterPlayerScripts in order for it to work
Alrighty thanks. You are right about the client sided not passing the player into the local script. I just tested and it printed “nil”, but it worked on the server side script.
I don’t know if I deserve the solution or @unidentifiedObject51 since if what they said was causing you problems, they deserve it more than me since I didn’t mention it