So I noticed today when I tested my game, that this function, that works in Studio, does not work. Any idea why? It is just a Script in Workspace, not a localscript.
wait(2)
local ResourceManager = require(game.ReplicatedStorage.ResourceManager)
local gui = game.Players.LocalPlayer.PlayerGui.PickupItemGui.ImageLabel
for _,v in next,game.Workspace.Items:GetChildren()do
v.ClickDetector.MouseClick:connect(function()
local objectType = v.ObjectType.Value
local data = ResourceManager.Resources[objectType]
gui.TextLabel.Text = data.Name
if gui.Visible == false then
gui.Visible = true
game.Players.LocalPlayer.PlayerGui.PickupItemGui.ImageLabel.ResourceType.Value = v.ObjectType.Value
else
end
end)
end
Ty!

4 comments
You can only use "LocalPlayer" in a localscript: the LocalPlayer is a client, and so the localscript return answer the client; think of it like in a business way: you, the employee, or local personal who answers calls, gets a call from a "client," and so you talk to & assist them; think of a localscript like that.
And for an explanation for the server-side, think of it like a group of construction workers; you try to talk to them, but they can't talk b/c they're busy & they're not allowed to (until they're off-work); that's essentially a server-side in a nutshell.
Makes sense. Thank you!
Np. :) Glad to help! :D