Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

script not updating text? Using remote events, Server to client.

Asked by 6 years ago
Edited 6 years ago

Soooo, long story short I want this script to update text for my game and it doesn't work for some reason and it gives no errors,

script:

01local Update = Instance.new("RemoteEvent")
02Update.Parent = game.ReplicatedStorage
03Update.Name = "Update"
04 
05local function UpdateStuff(player)
06    Update:FireClient(player)
07end
08while wait(0.5)do
09Players.PlayerAdded:Connect(UpdateStuff)   
10end

localscript:

01local Players = game:GetService("Players")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local amount = game.Players.LocalPlayer.PlayerGui.MainGui.Buttons["CLICK for CRATE BUX"].amount
04local player = Players.LocalPlayer
05local UpdateText = ReplicatedStorage:WaitForChild("Update")
06local playerGui = player:WaitForChild("PlayerGui")
07local Cost = playerGui.MainGui.Upgrades.Disc.Cost
08local function Update()
09playerGui.MainGui.Upgrades.Disc.Text = "+30 CRATE BUX per click ("..amount.Value..")"
10playerGui.MainGui.Upgrades.Disc['Buy for'].TextButton.TextButton.Text = "Upgrade for "..Cost.Value.."CB"
11playerGui.MainGui.Buttons['CLICK for CRATE BUX'].Text = "Click for "..amount.Value.."CB"       
12end
13 
14 
15 
16UpdateText.OnClientEvent:Connect(Update)

Any help to moi(me) will be amazing.

0
wait() shouldn't be a condition, and you don't have to loop the PlayerAdded event. User#19524 175 — 6y
0
But then it wouldn't update if the amount or cost increased or decreased If I don't add a loop the PlayerAdded thefatrat87 18 — 6y
0
What do you mean? PlayerAdded fires whenever a player joins. You don’t have to loop it will fire automatically. lunatic5 409 — 6y

Answer this question