My tycoon is an island one. Every tycoon is on a separate island. I want it to be so you spawn on the island only when the tycoon is not occupied. How would I do this? I am new at scripting.
Thanks!
My tycoon is an island one. Every tycoon is on a separate island. I want it to be so you spawn on the island only when the tycoon is not occupied. How would I do this? I am new at scripting.
Thanks!
I suppose you could add a BoolValue to the tycoon or the player (I’d prefer to the player as it’s less messy and easy to find) and then check for the BoolValue, if it is true (occupied) or false (available). However you could also just parent the BoolValues to the tycoon models and then loop through all the BoolValues and see if one of them is true or not.
Sorry if my explanation was messy but values such as StringValues, IntValues, BoolValues, ObjectValues always come in handy. Just do your checks on the server as the client can change any values with exploits.
local Islands = {
Island1 = false,
Island2 = false,
Island3 = false,
}
local IslandsSpawnPoints = {
Island1 = Vector3.new(10,10,10),
Island2 = Vector3.new(-10,10,10),
Island3 = Vector3.new(-10,10,-10),
}
local function CheckIsland(Player)
for i,v in pairs(Islands) do
if v == Player then
return i
end
end
end
local function ClaimIsland(Player)
for i,v in pairs(Islands) do
if v == false then
Islands[i] = Player
return i
end
end
end
local function UnclaimIslands(Player)
for i,v in pairs(Islands) do
if v == Player then
Islands[i] = false
end
end
end
game.Players.PlayerAdded:Connect(function(Player)
local Island = ClaimIsland(Player)
Player.CharacterAdded:Connect(function(Char)
Char:WaitForChild("HumanoidRootPart")
Char:MoveTo(IslandsSpawnPoints[Island])
end)
end)
game.Players.PlayerRemoving:Connect(function(Player)
UnclaimIslands(Player)
end)
Will this workk if I just put it in a script?