#Tycoon plot handler problem

1 messages · Page 1 of 1 (latest)

thorny needle
#

So uh, im basically working on a tycoon, and im working on getting the plots working or trying to atleast but it keeps making an error and wont let me claim any of the plots. Can someone help me with this?

thorny needle
# tranquil cloud 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

tranquil cloud
#

i see, could you copy and send the entire code here

thorny needle
# tranquil cloud 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

tranquil cloud
#

#

~

#

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)

thorny needle
#

Ohhh

#

hold on im gonna see if it works