Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i use a remote event for my localscript?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

: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)
0
in this case, woudn't it be better using a remoteFunction, as you can return a value Leamir 3138 — 3y
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. ArtFoundation 255 — 3y
0
Unless you do if statements and whatever to adjust your remote function to work with multiple functions I guess. ArtFoundation 255 — 3y
0
That will probably work acually. didn't think of that ill try it super00rocket 27 — 3y
View all comments (2 more)
0
nope super00rocket 27 — 3y
0
Well your original script is incorrectly using :FireClient(), don't know else how you're doing it wrong, probably your event connections? ArtFoundation 255 — 3y
Ad

Answer this question