I am trying to give a specific player a sound to play with RemoteEvents, but I don't really understand how to import the sound from the server script to the local script. This is what I have so far:
--LocalScript local RepStorage = game.ReplicatedStorage:WaitForChild("RemoteEvent") RepStorage.OnClientEvent:Connect(function(args) game.Workspace.ChaseTheme:Play() end) --ServerScript local ReplicatedStorage = game.ReplicatedStorage:WaitForChild("RemoteEvent") ReplicatedStorage:FireClient() --Loop Players (LocalScript) for _, r in pairs(game.Teams.Pearl:GetPlayers()) do local RepStorage = game.ReplicatedStorage:WaitForChild("RemoteEvent") RepStorage.OnClientEvent:Connect(function() game.Workspace.ChaseTheme:Play() end) end
First let's fix the misleading identifiers. Your variables are pointing to a remote event not the replicated storage.
Second you do not need the args
parameter if you won't use it.
What the issue is, you need a player to fire to, or else how will roblox know who to work with?
In this example I will get the player through PlayerAdded
.
--LocalScript local remote_event = game.ReplicatedStorage:WaitForChild("RemoteEvent") remote_event.OnClientEvent:Connect(function() game.Workspace.ChaseTheme:Play() end) --ServerScript local remote_event = game.ReplicatedStorage:WaitForChild("RemoteEvent") game:GetService("Players").PlayerAdded:Connect(function(client) remote_event:FireClient(client) -- pass a player reference end)