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

How do I make it so everytime someone chats a new part becomes a random position?

Asked by 3 years ago
1local pos1 = {250, 0, 250}
2local pos2 = {-250, 0, -250}
3game.Players.PlayerAdded:Connect(function(plr)
4    plr.Chatted:Connect(function()
5        local part = Instance.new("Part", game.Workspace)
6        part.Anchored = true
7        part.Position = Vector3.new(math.random(#pos1, #pos2))
8    end)
9end)

I am struggling please help.

2 answers

Log in to vote
1
Answered by 3 years ago

This should work

01--Must go from low to high
02x = math.random(0,100)
03y = math.random(0,100)
04z = math.random(0,100)
05 
06game.Players.PlayerAdded:Connect(function(Player)
07    Player.Chatted:Connect(function()
08        local part = Instance.new("Part", game.Workspace)
09        part.Anchored = true
10        part.Position = Vector3.new(x,y,z)
11    end)
12end)
0
The positions work but how can I make it so every time it's a different position because when I test it, it creates a random position but spawns in the same position pepsymax 73 — 3y
1
put the x, y, z before local part greatneil80 2647 — 3y
0
Yeah, that would work just put lines 2 through 4 below line 7 KripticalYT 100 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
01--pos1 dictionary--
02local pos1 =
03{
04250,
05 0,
06 250
07}
08--pos2 dictionary--
09local pos2 =
10{
11-250,
12 0,
13-250
14}
15game.Players.PlayerAdded:Connect(function(plr) --when player chats
View all 21 lines...

Answer this question