Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would i use a remote event for my localscript?

I have a local script that explains what i want the event to do. this is the script:

local event = game.ReplicatedStorage.DoCutsceneEvent
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart.CFrame
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
	Cutscene:Play()
	wait(Duration)
end

local function Cutscene()
	MoveCamera(game.Workspace.Cutscene1A, game.Workspace.Cutscene1B, 3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
	wait(1)
	game.Workspace.Truck.Truckdoor.Transparency = 1
	game.Workspace.Truck.Truckdoor.Graffiti.Transparency = 1
	game.Workspace.Truck.Truckdooropen.Transparency = 0
	wait(1)
	MoveCamera(game.Workspace.Cutscene1B, game.Workspace.Cutscene1A, 3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
	wait(.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
	wait(0.5)
end


	 
	event.OnClientEvent:Connect(function()
	Cutscene()
	end)

that was in the local script. i want to fire the event from a regular script and this is what i used:

local Cutscene = game.ReplicatedStorage.DoCutsceneEvent
Cutscene:FireClient()

I've tried many things, but nothing worked. I need help, any thoughts would help.

1 answer

:FireClient() requires a parameter, namely the player Instance you want to fire to. When you're firing the server from the local script and the server picks it up, it receives an argument that is the player object which you can use.

event.OnServerEvent:Connect(function(player)
    -- your code
    event:FireClient(player)
end)

6 comments

0

in this case, woudn't it be better using a remoteFunction, as you can return a value

0

Both work, whatever you prefer. I'm not really going to point that out because it's pretty minor and I think you can only attach one function to a RemoteFunction so in case you want to do multiple functions, remote events will be better in that case.

0

Unless you do if statements and whatever to adjust your remote function to work with multiple functions I guess.

0

That will probably work acually. didn't think of that ill try it

0

nope

0

Well your original script is incorrectly using :FireClient(), don't know else how you're doing it wrong, probably your event connections?

This discussion is preserved as it was. New answers, comments, and votes are closed.