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

Are you able to insert a RemoteEvent in a Player?

Asked by
c5or 8
6 years ago
Edited 6 years ago

I have this script in a player's Gui. When I test it in a localserver (Studio) the remoteevent shows in the player. But when I test it in an online server, it says that the remoteevent isn't there.

local Blue = Instance.new("RemoteEvent")
Blue.Name = "Blue"
Blue.Parent = script.Parent.Parent.Parent
Blue.OnServerEvent:connect(function()
    local c = game.Workspace.CurrentCamera  
    c.CameraSubject = game.Players.LocalPlayer.Character.Humanoid   
    c.CameraType = "Custom"
    c.FieldOfView = 70
if script:findFirstChild("SkipCutsceneGuiValue") then
    if script.SkipCutsceneGuiValue.Value ~= nil then
        script.SkipCutsceneGuiValue.Value:Destroy()
    end
end
wait(0.1)
script.Parent.Parent.Parent.TeamColor = BrickColor.new("Deep blue")
end)
0
You should keep all RemoteEvents and RemoteFunctions inside ReplicatedStorage. mattscy 3725 — 6y

1 answer

Log in to vote
0
Answered by
mraznboy1 194
6 years ago

You technically can, but the event would fail to do anything unless it was created by the server. The reason for this is because when using a remote event or function, both the client and server must be able to see the event/function. One of them will be firing/invoking the event/function, and the other will be connecting a function to the event/function. The reason this script doesn't work is because the local script creates the event in the client, and as a result it isn't replicated to the server, so it will do absolutely nothing. A better solution would be to either have a premade RemoteEvent object in the ReplicatedStorage (or any area that both the client and server can access), or to create the RemoteEvent object via script in the server, and have the client wait until the remote event is available.

0
Oh alright, thanks I'll do that. c5or 8 — 6y
Ad

Answer this question