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

Why is my frame not going visible using a RemoteEvent?

Asked by
Xyternal 247 Moderation Voter
2 years ago

So I was learning remoteEvents, and I wanted to make it so when some touches a part, then it triggers a local script which will print receive, and will also make the frame go visible. The problem, is that it will print receive, but it won't make the frame visible. Why? Script...

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnClientEvent:Connect(function()
    game.StarterGui.ScreenGui.Frame.Visible = true
    print("received ")
end)

1 answer

Log in to vote
2
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

When you spawn, GUIs are cloned from StarterGui into your PlayerGui, this means that if you change StarterGui you are not changing the current GUI but rather the one that you will get the next time you spawn, this is nicht gut, in order to solve it you simply need to change PlayerGui:

game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function()
    game:GetService("Players").LocalPlayer.PlayerGui.Frame.Visible = true
    print("received ")
end)

And don't use WaitForChild for anything in ReplicatedStorage, there is no need at all.

Ad

Answer this question