#How do I return to plot.Value = math.random(1, 6) if the plot*.Value == true?

1 messages · Page 1 of 1 (latest)

rose jewel
#

Players.PlayerAdded:Connect(function(player)
local plot = Instance.new("IntValue")
plot.Parent = player
plot.Name = "Plot"
plot.Value = math.random(1, 6)
if plot.Value == 1 and plot1.Value == false then
plot1.Value = true
plot1sign.Text = player.Name
end
if plot.Value == 2 and plot2.Value == false then
plot2.Value = true
plot2sign.Text = player.Name
end
if plot.Value == 3 and plot3.Value == false then
plot3.Value = true
plot3sign.Text = player.Name
end
if plot.Value == 4 and plot4.Value == false then
plot4.Value = true
plot4sign.Text = player.Name
end
if plot.Value == 5 and plot5.Value == false then
plot5.Value = true
plot5sign.Text = player.Name
end
if plot.Value == 6 and plot6.Value == false then
plot6.Value = true
plot6sign.Text = player.Name
end
print(player,"has claimed plot",plot.Value)
end)

mint fractal
#

You could probably use recursion

#

But in this case why would you need to return to plot.value == randomnumberbetween1and6

mint fractal
#

You don’t have to

undone nexusBOT
#

studio** You are now Level 2! **studio

mint fractal
#

In your code if the plot is claimed it just goes on to the next plot, no?

rose jewel
#

it's random

mint fractal
#

Ohhh wait I see

#

Sorry bout that

#

Is there any need for it to be random?

rose jewel
#

no

mint fractal
#

Oh okay, then a better way would to be to use an increment, every time a player joins you increase it moving the next player a plot over, that would be a more efficient and simple solution

#

I can write some code for how that might look and just in case you should probably test it with some other players because no guarantee it’s 100% right

rose jewel
#

k

undone nexusBOT
#

studio** You are now Level 5! **studio

rose jewel
#

i have 2 other ppl but idk when they are gonna hop on

mint fractal
#

Alright give me a minute since I’m on mobile

rose jewel
#

thanks

mint fractal
#

local PlotsTaken = 1

local plots = {
plot1,
plot2,
plot3,
plot4,
plot5,
plot6
}

Players.PlayerAdded:Connect(function(player)
    local plot = Instance.new("IntValue")
    plot.Parent = player
    plot.Name = "Plot"
    plot.Value = PlotsTaken
     local currentPlot = plots[plot.Value]
currentPlot.Value = true

    PlotsTaken += 1
    print(player,"has claimed plot",plot.Value)
end)

#

Damn it really is that difficult to write code on a phone

rose jewel
#

k thanks

mint fractal
#

Anyways this excluded the sign part but hopefully you can figure that out on your own

rose jewel
#

was i suppost to replace my origginal script

#

there is alot of errors

#

oh it's under my variables isn't it

mint fractal
#

No it’s not meant to replace your original script, just the piece you sent

rose jewel
#

oh k

mint fractal
#

Anyways I’ll be on tomorrow if there’s anything else you need hopefully I’ll be able to help better then

rose jewel
#

alr it works

#

local PlotsTaken = 1

local plots = {
plot1,
plot2,
plot3,
plot4,
plot5,
plot6
}

Players.PlayerAdded:Connect(function(player)
local plot = Instance.new("IntValue")
plot.Parent = player
plot.Name = "Plot"
plot.Value = PlotsTaken
local currentPlot = plots[plot.Value]
currentPlot.Value = true

PlotsTaken += 1
print(player,"has claimed plot",plot.Value)
if plot1 == true then
    plot1sign.Text = player.Name
end

end)

#

@mint fractal the sign isn't changing

#

i check the boolvalue in the workspace then change the text

#

after what u did

mint fractal
#

Uhh

#

You can make a table of the sign text values like I did with the plots before playeradded

#

And in player added