I'm making something where you claim an area if you walk up to it, and then nobody can walk into yours and you can't walk into anyone else's
In Studio it works perfectly, but when I go into the game with my alt, things get confusing
The touched events seem to only trigger when I do it, when my alt does it, literally nothing happens, and on top of that, it happens for everyone, not just me
What?
Code (ServerScript in ServerScriptService):
local Nil = game.Players:WaitForChild("Nil")
local Owner1 = Instance.new("StringValue")
local Owner2 = Instance.new("StringValue")
game.Players.PlayerAdded:Connect(function(player)
Nil.Parent = player
player.Nil.Value = true
end)
game.Workspace.Slot1.Ownership.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Owner1.Value == "" and Player.Nil.Value == true then
Owner1.Value = Player.Name
Player.Nil.Value = false
game.Workspace.Slot1.GUI.BillboardGui.TextLabel.Visible = false
else
return nil
end
if Player.Name == Owner1.Value then
game.Workspace.Slot1.Ownership.CanCollide = false
end
end
end)
game.Workspace.Slot2.Ownership.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Owner2.Value == "" and Player.Nil.Value == true then
Owner2.Value = Player.Name
Player.Nil.Value = false
game.Workspace.Slot2.GUI.BillboardGui.TextLabel.Visible = false
else
return nil
end
if Player.Name == Owner2.Value then
game.Workspace.Slot2.Ownership.CanCollide = false
end
end
end)

2 comments
now it just lets you walk into any claimed land
Updated, try that. I didn't see a need for new StringValue instances, so I converted them to variables.