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

value set to 1... print value: 1. value is set to text... 0??? (help plz)

Asked by 5 years ago
Edited 5 years ago

ok whats going on
so imagine this. you made a variable.

var = 1

then you made it print the variable

var = 1
print(var)

then you set it to a textlabel in a gui

var = 1
print(var)
script.Parent.textlael.Text = var

...then the textlabel said 0.
can somebody explain what causes this? my code:

sp = script.Parent
sp.winslabel.Text = "wins"
sp.losslabel.Text = "losses"

player = script.Parent.Parent.Parent.Parent
player:WaitForChild("wins")
player:WaitForChild("losses")
sp.playername.Text = player.name
 wins = player.wins.Value
 losses = player.losses.Value

data = game:GetService("TeleportService"):GetLocalPlayerTeleportData()
print(data)
datadata = data
if datadata == 1 then
--goes wrong in this loop
     wins = wins + 1
    player.wins.Value = player.wins.Value + 1
    print("win")
    sp.winswins.Text = wins
sp.losseslosses.Text = losses
print(wins)
print(losses)
end
if datadata == 0 then
--goes wrong in this if loop
     losses = losses + 1
    player.losses.Value = player.losses.Value + 1
    print("loss")
    sp.winswins.Text = wins
sp.losseslosses.Text = losses
print(wins)
print(losses)
end

thanks so much!

0
What does data print and is this in a LocalScript or Server Script? Azarth 3141 — 5y
0
its a localscript and data prints a 1 or 0 returning from another place codingMASTER398 52 — 5y

1 answer

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Edit: OP had a bigger problem where data wasn't being saved when the user was teleporting, so this was a data service error not related to this script. Fixed in team create.

local player = game.Players.LocalPlayer
local WinsStats = player:WaitForChild("wins")
local LossesStats = player:WaitForChild("losses")
local sp = script.Parent

sp.playername.Text = player.name
sp.winslabel.Text = "wins"
sp.losslabel.Text = "losses"

sp.winswins.Text = WinsStats.Value
sp.losseslosses.Text = LossesStats.Value

0
accepting for help. this script may not work codingMASTER398 52 — 5y
Ad

Answer this question