Script affects server but not client

  1. What do you want to achieve?
    A script that fades a gui for the client side.
	while true do
		game.StarterGui.bright.Frame.BackgroundTransparency = game.StarterGui.bright.Frame.BackgroundTransparency -0.01
		wait(0.01)
	end

  1. What is the issue?
    The script works fine on the server side, but does not affect the client at all.

  2. What solutions have you tried so far?
    I have tried changing it to a local script, but that just caused it to not work on the server or the client.

The local side requires PlayerGui instead of starterGui since all of startergui is simply replicated inside the player.

I changed both StarterGui s to PlayerGui but i got the error “PlayerGui is not a valid member of DataModel”

in a local script you can use
game.Players.LocalPlayer.PlayerGui

1 Like

That script actually does effect the clients too, you just weren’t doing it right. Maybe this would help?

It does? How is that possible? If you did it on a server script it wouldn’t replicate to the clients and if you did it on a local script it would simply be changing the startergui not the playergui

Changes to the server replicate to all the clients, otherwise if you do something in a server script, how would you, the client, see the change? Changing something on the client doesn’t replicate to to the server / the other clients though.

The problem is he’s changing the startergui version and not his playergui version.

I only see that happening if the player loads after the script is executed. Maybe I really dont understand this

I looked in that post, but the creator did not set a solution, and I don’t know what part I need to add/edit.

That makes sense, if you change something in the startergui then everyone who joins afterwards would receive that copy, which was updated. The startergui is just a container for all the guis, whenever you join, you get a copy of all the guis in startergui put in your playergui. This is why if you make a change to a gui in startergui, and then someone joins, they would get the changed version.

yes but he should be using PlayerGui instead. I dont think that script would work based on given information. Maybe im wrong. Ill test it right now

This was the post that I thought might help, but you should probably read up on StarterGui on the developer hub.

Yeah that’s the point I’m trying to make. The problem isn’t that he’s doing this in a server script but that he’s changing the starter gui’s version instead of your player gui’s version. Although it’s better to work with ui in local scripts so this should be a local script anyway. Maybe we should continue in dms because this post is getting pretty clogged.

I just get this when activating the script "Attempt to index nil with ‘PlayerGui’ " Also, its fine once we figure it out i can just set the solution for anyone who finds this.

You can’t use game.Players.LocalPlayer on the server so this would have to be a local script if you want to get the player like that. Where is this script?

It is a local script, and its in the workspace. I don’t know if it doesn’t work because the way I am doing it is this: It’s disabled, then i go into studio play mode, then i press server client and then enable it via explorer.

Local scripts have to be descended from the player/ the player’s character to run (for the most part).

Try this out: (This should be a local script inside your screengui)

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

while true do
	PlayerGui.bright.Frame.BackgroundTransparency = PlayerGui.bright.Frame.BackgroundTransparency -0.01
	wait(0.01)
end

Sorry if I’m being confusing.

1 Like

That works great, (and dont worry I am understanding you). However, it works fine if it is enabled before playing, but if i try to enable it during playing (via script and via explorer) it does not seem to work. I’ll set it as a solution since that is what I asked, the disable thing is a different topic sort of.

When you set the enable property you have to set it for the actual playerGui script not the starterGui btw. You can enable/disable by going inside your player