I've been trying to work out and come across possible explanations for this issue but I can't seem to identify the error.
I get the error, "Gift is not a valid member of PlayerGui".
Here is my script it is erroring in. Line 5. The script is also in Workspace as it is a RemoteEvent script.
game.ReplicatedStorage.Events.Present.OnServerEvent:Connect(function() -- Any code will run when RemoteEvent is triggered/fired for i,v in pairs(game.Players:GetPlayers()) do v.leaderstats.Points.Value = v.leaderstats.Points.Value + 5000 v.PlayerGui.Gift.cash.Visible = true v.PlayerGui.Gift.present.Visible = false game.Workspace.CoinSound:Play() v.leaderstats.gift.Value = true wait(0.2) v.PlayerGui.Gift.cash.TextSize = 40 wait(0.2) v.PlayerGui.Gift.cash.TextSize = 48 wait(2) v.PlayerGui.Gift.cash.Visible = false v.PlayerGui.Christmas.TextLabel.Visible = false end end)
Anyone know any possible explanations to this error?
Here is also a screenshot of the PlayerGui and the Gui's inside of it.
https://i.gyazo.com/20540f5b045018ba14e6a05e7c910cbf.png
Thanks, TheOnlySmarts.
use RemoteEvents
so the client can do it and you forgot to add the player parameter for OnServerEvent
.
local remote = game.ReplicatedStorage.Events.Present remote.OnServerEvent:Connect(function(player) -- Any code will run when RemoteEvent is triggered/fired for i,v in pairs(game.Players:GetPlayers()) do v.leaderstats.Points.Value = v.leaderstats.Points.Value + 5000 game.Workspace.CoinSound:Play() v.leaderstats.gift.Value = true remote:FireClient(player, "changeGui") end end)
client:
local remote = game.ReplicatedStorage.Events.Present local holder = script.Parent.Parent -- define where they are remote.OnClientEvent:Connect(function(changeGui) if changeGui == "changeGui" then holder.cash.Visible = true holder.present.Visible = false wait(0.2) holder.cash.TextSize = 40 wait(0.2) holder.cash.TextSize = 48 wait(2) holder.cash.Visible = false holder.Christmas.TextLabel.Visible = false end end)