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

RemoteEvent firing and received, but the script isn't working?

Asked by 5 years ago

The RemoteEvent fires and is received as it's prints it, but the PlayerGui parts do not work, as well as the CameraFix cloning into the Player's character.

train = game.ReplicatedStorage.C153
Camera = workspace.CurrentCamera


game.ReplicatedStorage.C153Spawn.OnServerEvent:connect(function(player)
    print("Event Received")
        player.PlayerGui.MainMenuGui.Screen.DriveFrame.Visible = false
        player.PlayerGui.MainMenuGui.Screen.Spawning.Visible = true
        player.PlayerGui.MainMenuGui.Screen.Spawning.Text = "Spawning..."
        wait(0.01)
        local clone = train:Clone()
        clone.Parent = workspace
        clone:MakeJoints()
        clone.Bogies.SD_Bogie:MakeJoints()
        clone.Bogies.SD_Bogie2:MakeJoints()
        wait(1)
        player.Character.HumanoidRootPart.CFrame = CFrame.new(-2449.474, 10.174, -198.335)
        player.PlayerGui.MainMenuGui.Screen.Spawning.Visible = false
        player.PlayerGui.MainMenuGui.Screen.IntroMusic:stop()
  script.Parent.CameraFix:clone().Parent = player.Character
end)

This is what is visible in the developer console: https://gyazo.com/80f97bddbd4561a789993d930de82abb

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

If your game is Fe, the server can't see the descendants of PlayerGui, so you're going to make a client-handled RemoteEvent for GUI manipulating.

Also, the camera is client-sided only

--Local script
wait()
local player = game.Players.LocalPlayer
local GuiStuff = game.ReplicatedStorage.GuiStuff

GuiStuff.OnClientEvent:Connect(function(bool)
        if bool then
               player.PlayerGui.MainMenuGui.Screen.DriveFrame.Visible = false
               player.PlayerGui.MainMenuGui.Screen.Spawning.Visible = true
               player.PlayerGui.MainMenuGui.Screen.Spawning.Text = 'Spawning'
        else
               player.PlayerGui.MainMenuGui.Screen.Spawning.Visible = false
               player.PlayerGui.MainMenuGui.Screen.IntroMusic:Stop()
        end
end)
--Server code
local train = game.ReplicatedStorage.C153
local GUI = game.ReplicatedStorage.GuiStuff

game.ReplicatedStorage.C153Spawn.OnServerEvent:Connect(function(player)
        GUI:FireClient(player, true)
        wait()
        local clone = train:Clone()
        clone.Parent = workspace
        clone:MakeJoints()
        clone.Bogies.SD_Bogie:MakeJoints()
        clone.Bogies.SD_Bogie2:MakeJoints()
        wait(1)
        player.Character.HumanoidRootPart.CFrame = CFrame.new(-2449.474, 10.174, -198.335)
       GUI:FireClient(player, false)
       script.Parent.CameraFix:Clone().Parent = player.Character
end)
0
No my game isn't FE and it works in Studio and did before this update that happened. CarlPlandog 20 — 5y
0
What is GuiStuff? CarlPlandog 20 — 5y
0
And it doesn't work anyway CarlPlandog 20 — 5y
0
What? You just said that it works in studio, also all games are Filtering Enabled. uhTeddy 101 — 5y
0
Well, I meant before I added this script that *my* script worked in studio. This one doesn't. CarlPlandog 20 — 5y
Ad

Answer this question