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

I'm Having an issue storing a number in a value?

Asked by
Bman8765 270 Moderation Voter
10 years ago

basically this localscript is trying to set a numbervalue to a random number but it wont work, any help? That is just a little of my code, it's not the whole thing but I think it is enough for you guys to find a solution. Whenever I check the output it appears that everything is running smooth but when testing it in studio I go into players and their startgui and the values have not changed.

----------------------------------------------------------------------------------------------------
repeat wait() until game.Players.LocalPlayer.Character
print("CardDealing script loading variables")
----------------------------------------------------------------------------------------------------
--Insert VARIABLES Below
----------------------------------------------------------------------------------------------------
playernameis = game.Players.LocalPlayer.Name
nameoutput = script.Parent.MyName.Value
Begin = script.Parent.BeginBut
ScrollingInfo = script.Parent
player1 = game.Workspace.Player1.PlayerName
player2 = game.Workspace.Player2.PlayerName
p1r1 = script.Parent.Row1.Value
p1r2 = script.Parent.Row2.Value
p1r3 = script.Parent.Row3.Value
p1r4 = script.Parent.Row4.Value
----------------------------------------------------------------------------------------------------
print("CardDealing script working")
----------------------------------------------------------------------------------------------------

nameoutput = playernameis
Randomcardone = math.random(5)
Randomcardtwo = math.random(5)
Randomcardthree = math.random(5)
Randomcardfour = math.random(5)
p1r1 = Randomcardone
p1r2 = Randomcardtwo
p1r3 = Randomcardthree
p1r4 = Randomcardfour

1 answer

Log in to vote
4
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

This question is asked very often....


Modifying p1r1 modifies the variable p1r1.

When you earlier set p1r1 to script.Parent.Row1.Value, it said "Oh, p1r1 is gonna be zero now".

It in no way somehow "linked" the Value property of Row1 with the variable p1r1.


You must explicitly set the Value property in order to change the value property.

row1 = script.Parent.Row1

row1.Value = math.random(5)
0
thank you so much, I'm glad there are users like you that don't look at me like an idiot and actually explain it! Bman8765 270 — 10y
Ad

Answer this question