#Tycoon plot handler problem
1 messages · Page 1 of 1 (latest)
What's the error?
Im gonna try to explain the best that i can, but every time when i try to claim a plot. Nothing att all happens, and you can see in the code there's an error but i dont know how to fix it.
its on line 21
i see, could you copy and send the entire code here
local Plots = game.Workspace.Plots
-- Player joins a game
game.Players.PlayerAdded:Connect(function(player)
-- Get a plot
for _, plot in Plots:GetChildren() do
if plot:GetAttribute("Taken") then continue end
-- plot is not taken, so we want to take it --
plot:SetAttribute('Taken', true)
plot:SetAttribute('Owner', player.UserId)
print('Plot has been given to'..player.Name..'!')
break
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for _, plot in Plots:GetChildren() do
if not plot:GetAttribute('Owner') then continue end
-- plot is owned by a player
if plot:GetAttribute('Owner') ⁓= player.UserId then continue end
-- we have found the correct plot
plot:SetAttribute('Taken', nil)
plot:SetAttribute('Owner', nil)
print('Plot has been removed from'..player.Name..'!')
end
end)
idk whats wrong with it
⁓
~
See
The operator is wrong
local Plots = game.Workspace.Plots
game.Players.PlayerAdded:Connect(function(player)
for _, plot in Plots:GetChildren() do
if plot:GetAttribute("Taken") then continue end
plot:SetAttribute("Taken", true)
plot:SetAttribute("Owner", player.UserId)
print("Plot has been given to "..player.Name.."!")
break
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for _, plot in Plots:GetChildren() do
if not plot:GetAttribute("Owner") then continue end
if plot:GetAttribute("Owner") ~= player.UserId then continue end
plot:SetAttribute("Taken", nil)
plot:SetAttribute("Owner", nil)
print("Plot has been removed from "..player.Name.."!")
break
end
end)
@tranquil cloud ty man