local GroupId = 5162592
local AllowedRank = 103
local Room = game.ReplicatedStorage.RoomsForTrainings.BaristaTrainingRoom:Clone()
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(chat)
if chat =="!room Barista" and Player:GetRankInGroup(GroupId) >= AllowedRank then
Room.Parent = game.Workspace
Room.FunctionalProperties.TeleSpawn.Position = Vector3.new(Random.new(1000,1000000), Random.new(1000,1000000), Random.new(1000,1000000))
else
end
end)
end)
The context:
I’m trying to make a script that will clone a model from replicated storage, then place it in a random position in the workspace.
The issue:
It only clones once, and always in the same place.
What I think went wrong;
I’m genuinely blank here.
It’s because you only made one clone at the beginning of the script
Try this:
local GroupId = 5162592
local AllowedRank = 103
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(chat)
if chat =="!room Barista" and Player:GetRankInGroup(GroupId) >= AllowedRank then
local Room = game.ReplicatedStorage.RoomsForTrainings.BaristaTrainingRoom:Clone()
Room.Parent = game.Workspace
Room.FunctionalProperties.TeleSpawn.Position = Vector3.new(Random.new(1000,1000000), Random.new(1000,1000000), Random.new(1000,1000000))
else
end
end)
end)
For the problem of it being in the same place, I honestly have no clue sorry. Also noticed you are only moving the telespawn and not the whole room. Why is that?
local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Rooms = Replicated.RoomsForTrainings
local Room = Rooms.BaristaTrainingRoom
local GroupId = 5162592
local RequiredRank = 103
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message:lower() == "!room barista" then
local Succ, Res = pcall(function()
return Player:GetRankInGroup(GroupId)
end)
if Succ then
if Res then
if Res >= RequiredRank then
local RoomClone = Room:Clone()
Room.FunctionalProperties.TeleSpawn.Position = Vector3.new(math.random(1000, 1000000), math.random(1000, 1000000), math.random(1000, 1000000))
end
end
else
warn(Res)
end
end
end)
end)