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:

local Update = Instance.new("RemoteEvent")
Update.Parent = game.ReplicatedStorage
Update.Name = "Update"

local function UpdateStuff(player)
    Update:FireClient(player)
end
while wait(0.5)do
Players.PlayerAdded:Connect(UpdateStuff)    
end

localscript:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local amount = game.Players.LocalPlayer.PlayerGui.MainGui.Buttons["CLICK for CRATE BUX"].amount 
local player = Players.LocalPlayer
local UpdateText = ReplicatedStorage:WaitForChild("Update")
local playerGui = player:WaitForChild("PlayerGui")
local Cost = playerGui.MainGui.Upgrades.Disc.Cost
local function Update()
playerGui.MainGui.Upgrades.Disc.Text = "+30 CRATE BUX per click ("..amount.Value..")"
playerGui.MainGui.Upgrades.Disc['Buy for'].TextButton.TextButton.Text = "Upgrade for "..Cost.Value.."CB"
playerGui.MainGui.Buttons['CLICK for CRATE BUX'].Text = "Click for "..amount.Value.."CB"        
end



UpdateText.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