Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

2 comments

0

What does data print and is this in a LocalScript or Server Script?

0

its a localscript and data prints a 1 or 0 returning from another place

1 answer

✓ Accepted answer

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

1 comment

0

accepting for help. this script may not work

This discussion is preserved as it was. New answers, comments, and votes are closed.