So I am making a chunk claiming system, and while claiming land works, it only works for one player. Then other players cant claim land.
local CanShow = true
local ts = game:GetService("TweenService")
spawn(function()
game.ReplicatedStorage.Events.ShowLandInfoUI.OnClientEvent:Connect(function(Owner, ChunkID)
_ChunkID = ChunkID
CanShow = true
if Owner == "Unclaimed" then
CanShow = true
else
CanShow = false
end
while game:GetService("RunService").Stepped:Wait() do
if CanShow == true then
ts:Create(
script.Parent,
TweenInfo.new(
0.5,
Enum.EasingStyle.Linear
),
{
Transparency = 0
}
):Play()
else
ts:Create(
script.Parent,
TweenInfo.new(
0.5,
Enum.EasingStyle.Linear
),
{
Transparency = 1
}
):Play()
end
end
end)
end)
spawn(function()
game.ReplicatedStorage.Events.HideLandInfoUI.OnClientEvent:Connect(function()
CanShow = false
ts:Create(
script.Parent,
TweenInfo.new(
0.5,
Enum.EasingStyle.Linear
),
{
Transparency = 1
}
):Play()
end)
end)
script.Parent.MouseButton1Click:Connect(function(Player)
for i,v in pairs(workspace.Land_Chunks:GetDescendants()) do
if v.ClassName == "StringValue" then
if v.Value == _ChunkID then
game.ReplicatedStorage.Events.ClaimLand:FireServer(game.Players.LocalPlayer.Name)
end
end
end
end)
that is the code inside the button to claim land. It works for one player, but then it stops working. The chunk id is an ID thats passed over when a player walks into the zone
local ZoneM = require(game.ReplicatedStorage.Libraries.Zone)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Container = script.Parent
local Zone = ZoneM.new(Container)
task.wait(0.5)
Zone.playerEntered:Connect(function(Player)
ReplicatedStorage:WaitForChild("Events").ShowLandInfoUI:FireClient(Player, script.Parent.Owner.Value, script.Parent.ChunkID.Value)
end)
Zone.playerExited:Connect(function(Player)
ReplicatedStorage:WaitForChild("Events").HideLandInfoUI:FireClient(Player)
end)
theres the code that fires the events and stuff to show stuff