Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why will studio see that a player has a GUI but not in the real game?

In studio, this script works perfectly:

game.ReplicatedStorage.spon1.OnServerEvent:Connect(function(player)
local a =	Instance.new("StringValue")
	a.Name = "spon"
	a.Value = player.Sponsor.Frame.items.a.Text
	a.Parent = game.ReplicatedStorage.Sponsored
end)

However, when I try it in the real game, it says that 'sponsor is not a vaild member of playergui', when it is. Does anyone have any idea why this is happening?

1 answer

Assuming this is in a Script, you cannot access the PlayerGui through the server. You need to use a LocalScript for that. The reason it works in Studio and not in the game is that in Studio Solo Mode, the client and server aren't separated. This can allow LocalScripts to do things server scripts should be doing, and vice versa.

4 comments

0

when I try to make a string value through a local script, that doesnt work also

0

What do you mean? The StringValue you are trying to create in the code you put in your question?

0

In the Solo mode, everything is not run locally, it is the client and server are not separated, this is why LocalScripts may be able to access ServerStorage, or a Script accessing UserInputService, when in a resl server this is not allowed. You should edit your answer.

0

Yeah, I messed that up. My bad.

This discussion is preserved as it was. New answers, comments, and votes are closed.