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

How do I make a text label change with local script?

Asked by
MediaHQ 53
4 years ago
Edited 4 years ago

Alright so I am making a paycheck script and I am making it so it pops up with a notification that you received the money. The paycheck depends on the player's team. But instead of showing the money a player received, it shows 0. How do I fix this? My code (Local):

01local MoneyValue = workspace.Leaderboard.PayCheck.Value
02 
03script.Parent.Text = "You've Received $"..MoneyValue --Updates the money with value doesn't work
04 
05while wait(60) do
06    script.Sound.Playing = true
07    script.Sound.Looped = false
08    script.Parent.Parent.Visible = true
09    wait(5)
10    script.Sound.Playing = false
11    script.Parent.Parent.Visible = false
12end

It still gives the money to the player but I want this to show the money the player has received Edit 1: After changing teams it will show the money a player has gotten but from the last team Leaderboard Script (Just in case):

01local datastore = game:GetService("DataStoreService")
02local ds1 = datastore:GetDataStore("CashSaveSystem")
03 
04game.Players.PlayerAdded:Connect(function(plr) -- Capital 'C'
05    local folder = Instance.new("Folder", plr)
06    folder.Name = "leaderstats"
07    local cash = Instance.new("IntValue", folder)
08    cash.Name = "Money"
09 
10    cash.Value = ds1:GetAsync(plr.UserId) or 500
11    ds1:SetAsync(plr.UserId, cash.Value)
12 
13    cash.Changed:connect(function()
14        ds1:SetAsync(plr.UserId, cash.Value)
15    end)
View all 43 lines...
0
I have a similar problem to this, I can't can't get my text GUI to change when your player dies........ astonplep 32 — 4y
0
cant you get the leaderstats from the player? BeyondTheEgde 0 — 4y
0
also i think using a local script might be unnecessary BeyondTheEgde 0 — 4y

1 answer

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
4 years ago
Edited 4 years ago

As far as I understand, you are working very hard to avoid using RemoteEvents. While this might work, it is going to be a nightmare to synchronize properly. Making shenanigans like this sooner or later turn your scripts into a spaghetti code.

While your script could be fixed, I will update it to use RemoteEvent anyway. It would break for example when two players join at the same time. No more excuses, you need to start using Remotes, or you will never make a fully functional game.

Local Script:

01local PayCheckEvent = game.ReplicatedStorage:WaitForChild("PayCheckEvent")
02 
03local function OnPayCheckEvent(amount)
04   script.Parent.Text = "You've Received $" .. amount
05    script.Sound.Playing = true
06    script.Sound.Looped = false
07    script.Parent.Parent.Visible = true
08    wait(5)
09    script.Sound.Playing = false
10    script.Parent.Parent.Visible = false
11 
12end
13PayCheckEvent.OnClientEvent:Connect(OnPayCheckEvent)

ServerScript:

01local datastore = game:GetService("DataStoreService")
02local ds1 = datastore:GetDataStore("CashSaveSystem")
03 
04local PayCheckEvent = Instance.new("RemoteEvent")
05PayCheckEvent.Name = "PayCheckEvent"
06PayCheckEvent.Parent = game.ReplicatedStorage
07 
08 
09 
10game.Players.PlayerAdded:Connect(function(plr) -- Capital 'C'
11    local folder = Instance.new("Folder", plr)
12    folder.Name = "leaderstats"
13    local cash = Instance.new("IntValue", folder)
14    cash.Name = "Money"
15 
View all 48 lines...

Hope this helps. Edit: I changed player to plr in server script.

0
I avoid remotefunctions because they really hard to understand MediaHQ 53 — 4y
Ad

Answer this question