You’re attempting to change the players cash from their client, which only they can see. You’ll have to look into using a remoteevent. Which essentially serves as a way for a client to communicate with the server. If this all sounds confusing, here’s some tutorials. I understand how you feel lol.
This thread is just going back and forth with question and reply.
Here is what needs to be done:
-
You cannot use StarterGui to change guis that are already in a Player, change this to
player.PlayerGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
-
You need to create a
REMOTE EVENT
, when the LocalScript detects the MouseClick it will Fire to the server, which then will add to the Cash value. -
Unless this is intentional you spelt Cash wrong:
if u have read the last post’s this post has already been solved. So i don’t think its nesecarry for more replies on the same input.
This is the problem, first of all your changing the cash from a local script which doesnt replicate to the server, Second of all your doing this from the Startergui. The staergui gets copied to the player when the player loads in the game. By doing this:
game.StarterGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
You arent connecting to the event to the gui the player has. Statergui is just something which gets copied to all the players.If you want it to work then use relative location instead of absolute location, by doing script.Parent ect. If you really want to use absolute location do this
game.Players[game.Players.LocalPlayer.Name].PlayerGui.CashGui.MouseButtonOneClick:Connect(function)
You cannot change a value from a LocalScript as it will not show for the server and StarterGui is a container for the guis getting copied into PlayerGui, which is where the guis are.
To fix this, use a RemoteEvent and use
player:WaitForChild(“PlayerGui”):WaitForChild(“ScreenGui”):WaitForhild(“TextButton”).MouseButton1Click:Connect(function()
I used WaitForChild as the gui and PlayerGui might not be loaded at the time of when the script runs.
Off topic but…
Please use ```
to wrap your code in a LUA format.
For example:
``` print("test") ```