so i am making a window and you can open it and go trought it once its open, i used a proximity prompt and tween and everything works fine except that i cant play an animation with the global script i tried using a remote event but the computer gets confused and dosent understand who to fire to function to when its not to the all clients. How can i play the animation to the client who intereacts with the window?
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated.RemoteEvent
local Prompt = script.Parent
Prompt.Triggered:Connect(function(Player)
Remote:FireClient(Player) --Pass additional arguments if necessary.
end)
When a ProximityPrompt instance is triggered the player instance which triggered it is automatically passed as an argument to any connected callback function. With this, we can fire the client for which this player instance belongs to/is associated with by calling “:FireClient()” through a RemoteEvent instance and passing the same player instance as its first argument (additional arguments can also be passed).
Then all you’ll need is a local script which listens for this “:FireClient()” instance method to be called through/on the same RemoteEvent instance with an event listener (the OnClientEvent event), for the above example, that will look like the following.
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:WaitForChild("RemoteEvent")
Remote.OnClientEvent:Connect(function()
--Perform animation here.
end)
thank you but there is one more problem i get confused at this line
“Remote:FireClient(Player) --Pass additional arguments if necessary.”
how do i exatcly tell him to fire the function to the local player i tried different ways but it diddnt really worked
That’s the purpose of “Player”, it’ll only fire to the client for which that player instance belongs to.
i wrote that and it gave me an error saying
12:19:14.171 FireClient: player argument must be a Player object - Server - Script:3
edit: its ok now its all fixed