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

TextLabel.Text is not being changed, but passed value is working?

Asked by 3 years ago
Edited 3 years ago

What the actual hell!

So, why the freak is this not working?

-- Script in SSS

if game:GetService("MarketplaceService"):PlayerOwnsAsset(CurrentPlayer, DoubleCoinGP) then 
                local RewardAmountDB = RewardedTime * 2
                --CurrentPlayer.leaderstats.Cash.Value = CurrentPlayer.leaderstats.Cash.Value + RewardAmountDB
                print(CurrentPlayer.Name,' has been rewarded ',RewardAmountDB,' cash')
                CashToReward = CashToReward + RewardAmountDB
            end
            local RewardAmountDB = nil
            if CurrentPlayer.MembershipType == Enum.MembershipType.Premium then
                local RewardAmountDB = RewardedTime * 2
                print(CurrentPlayer.Name,' has been rewarded ',RewardAmountDB,' cash')
                --CurrentPlayer.leaderstats.Cash.Value = CurrentPlayer.leaderstats.Cash.Value + RewardAmountDB
                CashToReward = CashToReward + RewardAmountDB
            end
            CashToReward = CashToReward + RewardedTime
            print('CashToReward = ',CashToReward)
            local XPTeReward = 0
            if game:GetService("MarketplaceService"):PlayerOwnsAsset(CurrentPlayer, TwiceXP) then 
                XPTeReward = RewardedTime / 2
                print(CurrentPlayer.Name,' has been rewarded ',math.round(RewardedTime / 1),' XP ')
            else
                XPTeReward = RewardedTime / 4
                print(CurrentPlayer.Name,' has been rewarded ',math.round(RewardedTime / 2),' XP')
            end

PreloadRewardUI:FireClient(CurrentPlayer,XPTeReward,CashToReward)

--LocalScript in GUI


function PreloadUI(XP,Cash) print("Received order to change ",Player.Name,"'s CashText.Text from ",CashText.Text,' to ',Cash) -- (Output) Received order to change Player1 's CashText.Text from 999 to 23 print("Received order to change ",Player.Name,"'s XPText.Text from ",XPText.Text,' to ',XP) -- (Output) Received order to change Player1 's XPText.Text from 999 to 5.75 script.Parent.Left.Block.Frame.TextLabel.Text = ''..XP..'.' -- IT DOES NOT CHANGE THE TEXT. It just keeps saying 999 script.Parent.Right.Block.Frame.TextLabel.Text = ''..Cash..'.' -- NOR THESE TEXTS ARE CHANGED. It just keeps saying 999 end PreloadRewardUI.OnClientEvent:Connect(PreloadUI)

So, anyone have a clue?

Edit:

This does not work too:

local NewCashText = Cash
    local NewXPText = XP
    print("Received order to change ",Player.Name,"'s CashText.Text from ",CashText.Text,' to ',NewCashText)
    print("Received order to change ",Player.Name,"'s XPText.Text from ",XPText.Text,' to ',NewXPText)
    script.Parent.Left.Block.Frame.TextLabel.Text = ''..NewXPText..'.'
    script.Parent.Right.Block.Frame.TextLabel.Text = ''..NewCashText..'.'
0
Made them both to 'Local Function', but did not fix it. HeadlessDeathSpeaker 9 — 3y
0
May I know these XP and Cash are numeric or string? BestCreativeBoy 1395 — 3y
0
They are both Numbers HeadlessDeathSpeaker 9 — 3y
0
I've edited the post with some more context btw HeadlessDeathSpeaker 9 — 3y
View all comments (2 more)
0
Try using tostring(XP) and tostring(Cash) BestCreativeBoy 1395 — 3y
0
What's Tostring? Can't find anything about that on Google nor Yahoo, lol HeadlessDeathSpeaker 9 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I might have potentially found the error. While examining about the stuff in comments, I might have found the error. The problem is maybe TextLabel is not accepting number value. So, you have to convert it to string.

Here's what you must do:

function PreloadUI(XP,Cash)

local Xp = tostring(XP) -- Convert XP to string
local cash = tostring(Cash) -- Convert Cash to string

    print("Received order to change ",Player.Name,"'s CashText.Text from ",CashText.Text,' to ',Cash)
    print("Received order to change ",Player.Name,"'s XPText.Text from ",XPText.Text,' to ',XP) 
    script.Parent.Left.Block.Frame.TextLabel.Text = ''..Xp..'.' 
    script.Parent.Right.Block.Frame.TextLabel.Text = ''..cash..'.' 
end

PreloadRewardUI.OnClientEvent:Connect(PreloadUI)

Lemme know if it helps!

0
Oh, now I get it. To-String, Tostring. I thought it was Tost-ring, ghehehe. HeadlessDeathSpeaker 9 — 3y
Ad

Answer this question