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

Why will this OnServerEvent not working?

Asked by 7 years ago
workspace.LevelUp.OnServerEvent:connect(function(player)
    game.Players.player.StarterGui.MainGui.LevelUpFrame.Visible = true
end)

1 answer

Log in to vote
0
Answered by
oSyM8V3N 429 Moderation Voter
7 years ago
Edited 7 years ago

1.You can only use OnServerEvent in serverscripts 2.You have to connect the event not 'workspace.LevelUp' 3.You can't call "Players.player" thats gonna be an error

Since in the function(player) you already called a player, you could just use player.StarterGui instead of game.Players.player.

This should be the correct code :

|ServerScript|

local Event = writewhereyoureventislocated

Event.OnServerEvent:connect(function(player)
player.StarterGui.MainGui.LevelUpFrame.Visible = true
end)

Hope this helps!

Ad

Answer this question