To be clear, it may be obvious (it wasn’t to me until I started researching), RE stands for RemoteEvent (lool, most of you guys probably knew that)
Anyways, I am trying to fire a RemoteEvent to the client that will start a camera tween (all this is through a BindableEvent, not important because I’ve made sure that it works but thought I should say it). I do not know whether the tween works, although I think it does but I haven’t been able to test it in a RemoteEvent.
Code (Client and Server):
-- Server sided (Script in ServerScriptService)
script:WaitForChild("Event").Event:Connect(function(player)
print("fired")
game.ReplicatedStorage.ActivateTween:FireClient(player)
end)
-- Client (LocalScript in StarterGui)
game.ReplicatedStorage.ActivateTween.OnClientEvent:Connect(function()
local TweenService = game:GetService("TweenService")
local cutsceneTime = 1
local camera = game.Workspace.Camera
local tweenInfo = TweenInfo.new(
cutsceneTime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local function tween(part1, part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
camera.CameraType = Enum.CameraType.Custom
print("CutsceneDone")
end
wait(2)
tween(game.Workspace.Test1,game.Workspace.Test2)
end)
Now the hard part! Getting the player object (everyones favorite part of RemoteEvents)!!! I get an error in the Output saying this…
18:16:18.315 FireClient: player argument must be a Player object - Server - MainController:5
I should also make it clear- I have tried researching this, and have had no luck what so ever. Including developer forums topics, it still doesn’t work.
On “MainController” line 3 you define script:WaitForChild("Event").Event:Connect(function(player). where is this event being fired from? I don’t believe you’re passing it a player
script:WaitForChild("Event").Event:Fire(player) Like this, you pass the player argument to the event’s Fire. It would help to see the actual script firing this event.
Oh, thought you meant something else. I’m firing this from ServerScriptService. I’ve looked at some of Roblox’s code and they did this. For some reason, it isn’t working for me. May it be that this is from a bindable event function?
QueueAnimation is a BindableEvent inside a script in ServerScriptService
this is what receives it (and then fires the remote event, which is where I run into my problem.
print("Script up and running.")
script:WaitForChild("QueueAnimation").Event:Connect(function(player)
print("fired")
game.ReplicatedStorage.ActivateTween:FireClient(player) -- Fires remote event to client
end)
ActivateTween is a RemoteEvent in ReplicatedStorage.
So now, the problem is this, on line three of the script that receives the BindableEvent (the script on the bottom of the 2 scripts here), is that I need to find a player object.