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

How to use math.random?

I'm having a bit of trouble with this. It says I can't use math.random, but I'm not sure what else to use. 'Up' is a member of the Player (There's a script for it). Could someone help me out?

s = game.Workspace:GetChildren()

function Down()
	for i,v in pairs(game.Workspace:GetChildren()) do
			if v.Name == "SpawnLocation" then
				plr.Character:MoveTo(math.random(1,v.Position))
				a = false
			end
	end
end

function Up()
	for i,v in pairs(game.Workspace.Lobby:GetChildren()) do
		if v.Name == "SpawnLocationU" then
			plr.Character:MoveTo(math.random(2,v.Position))
		end
	end
end

game.Players.PlayerAdded:connect(function(p)
	game.Workspace.CharacterAdded:connect(function(char)
		if p.Up.Value == false then
			Down()
		elseif p.Up.Value == true then
			Up()
		end
	end)
end)

3 comments

0

Player is not defined so I'm going to do major editing! :)

0

Can you cut off the parts you do not have errors on?

0

@Hex, You may be right. Fail..... I'll go check it out (I was helping him with this script)

1 answer

You probably have to specify what X/Y/Z Position you are using.

1 comment

0

He does not have to do that.

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