Local script in workspace!

So when I try to make it so that a part with a surface gui shows something from the players leaderstats/playerValues it doesnt work, there are no errors and its a local script can soemone help me?

This is the script:

local player = game.Players.LocalPlayer

script.Parent.Text = player.PlayerValues.LuckUpgrades.Value.."/"..player.PlayerValues.MaxLuckUpgrades.Value

player.PlayerValues.LuckUpgrades:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = player.PlayerValues.LuckUpgrades.Value.."/"..player.PlayerValues.MaxLuckUpgrades.Value
end)
4 Likes

Local scripts dont work in workspace
A LocalScript will only run Lua code if it is a descendant of one of the following objects:

https://create.roblox.com/docs/reference/engine/classes/LocalScript

4 Likes

so how do I make a suraface gui show seomthing for only one player?

1 Like

The point of local scripts it to make something happen only for a specific player. Just insert the local script in one of the instances mentioned by @MrKlocek2 and it will work. If this is a local script, every player might see something different on this surface GUI. If it was a server script, everyone would see the same thing.

1 Like

I don’t know if Roblox plans to deprecate one day LocalScripts, but they added a way for you turn Scripts into LocalScript.

So insert a “default” Script and change it’s RunContext to Client and paste all your code in that script, that should work.

(Idk if this feature is still in beta or completely released)

3 Likes

Put the SurfaceGui inside PlayerGui/StarterGui, and make it visible on the client side.

RunContext has been fully released for months.

1 Like

How would I do that__________?

Actually knowing your goal I’m pretty sure you could edit the UI of the player from the server by accessing it’s PlayerGui and changing the specific targeted GUI, for example;

player.PlayerGui.ScreenGui.TextLabel.Text = "something lolol"

This will change the ScreenGui for the player, however this still technically counts as a server change becausue you’re modifying it from the server, this only replicates it to the client - say you have two clients controlling one actual player (where you can atleast have two localscripts for each client and one playergui shared across them), this would appear across both clients’ screens.

FYI this change is live for everyone, but I don’t think it’ll deprecate LocalScripts - anyway the RunContext being set to Client does the same thing as a LocalScript, actually - unless there are major differences, LocalScripts can be inserted which is faster than inserting a Script and changing it’s RunContext. If you mean it bypasses Filtering Enabled or it can run in workspace, I can see why you think it would deprecate LocalScripts.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.