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

Why isn't the Value changing?

Asked by 5 years ago
Edited 5 years ago

Hi i am making a zombie wave game and i decided to add a map voting system. I was trying to randomize the map that applies to each of the things you can vote for, I was able to randomize the name but i also made a value in the frame that the name applies to called map. This value is for the main script to call what map was most voted for but the value doesn't change in the map randomizer script.

local map = math.random(3)
    if map == 1 then
    script.Parent.Parent.Map.Value = 1
    script.Parent.Parent.TextButton.Text = "Grasslands" 
end
  if map == 2 then
    script.Parent.Parent.Map.Value = 2
    script.Parent.Parent.TextButton.Text = "The Ditch" 
end
      if map == 3 then
        script.Parent.Parent.Map.Value = 3
    script.Parent.Parent.TextButton.Text = "Volcano"
end

this is the script and as you can see it chooses between 3 maps and puts the name of the map on the text button you click on to vote for the map, it also should change the map value(it is a number value) if it is chosen but it always stays at 0 help please.

0
line 1, math.random(1,3) greatneil80 2647 — 5y
0
This code is bad iuclds 720 — 5y

1 answer

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
5 years ago
Edited 5 years ago
local Maps = {'Grasslands','The Ditch','Volcano'}
local Map = Maps[math.random(#Maps)]

if Map == 'Grasslands' and not nil then
script.Parent.Parent.Map.Value = 1
script.Parent.Parent.TextButton.Text = "Grasslands" 
elseif

Map == 'The Ditch' and not nil then
script.Parent.Parent.Map.Value = 2
script.Parent.Parent.TextButton.Text = "The Ditch" 
elseif

Map == 'Volcano' and not nil then
script.Parent.Parent.Map.Value = 3
script.Parent.Parent.TextButton.Text = "Volcano"
end

If you need to use remote events then do https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

Ad

Answer this question