I am getting an error that I don’t know how to fix.
When the owner of the tycoon leaves, the dropper is being reset for them, however the players in the game who are not the owner of the tycoon, the dropper isn’t being reset for them and stays visible. When the owner of the dropper leaves, it should show to the players in the game who are not the owner of that tycoon that the button is visible again and the dropper is invisible.
local Players = game:GetService("Players")
local localtween = require(game.ServerStorage.LocalTween)
local CollectionService = game:GetService("CollectionService")
local Teams = game:GetService("Teams")
local dropperButton1 = game.Workspace.LamarDropperButtonsUp.Dropper1Button
local base = script.Parent
local dropper1 = game.Workspace.DroppersFolder.LamarUpDroppers.Dropper1Lamar
local PricingTag = script.Parent.Parent.PricingTag
local lamarClaim = game.Workspace.Claim.LamarClaim
local tweenInfo = {0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false}
local dropper1Tweens = {}
local properties = {
Transparency = 0,
CanCollide = true
}
for _, parts in ipairs(dropper1:GetChildren()) do
parts.Transparency = 1
parts.CanCollide = false
end
local function resetDropperAttributesandButton()
dropper1:SetAttribute("Claimedby", false)
end
base.Touched:Connect(function(otherPart)
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
local leaderstats = player:FindFirstChild("leaderstats")
if player.Team == Teams.Lamar and leaderstats.Cash.Value == 0 then
dropper1:SetAttribute("Claimedby", player.UserId)
if dropper1:GetAttribute("Claimedby") == player.UserId then
for _, dropper1Parts in ipairs(dropper1:GetChildren()) do
dropper1Tweens[dropper1Parts] = localtween.Tween(dropper1Parts, tweenInfo, properties)
end
for _, parts in ipairs(dropperButton1:GetChildren()) do
parts.Transparency = 1
parts.CanCollide = false
parts.CanTouch = false
PricingTag.BillboardGui.Frame.Visible = false
end
end
end
end)
Players.PlayerRemoving:Connect(function(player)
if player.UserId == dropper1:GetAttribute("Claimedby") then
resetDropperAttributesandButton()
else
print("no")
end
end)
dropper1:GetAttributeChangedSignal("Claimedby"):Connect(function(attribute)
if attribute == false then
print("It is false")
for _, parts in ipairs(dropperButton1:GetChildren()) do
parts.Transparency = 0
parts.CanCollide = true
parts.CanTouch = true
PricingTag.BillboardGui.Frame.Visible = true
end
for _, parts in ipairs(dropper1:GetChildren()) do
parts.Transparency = 1
parts.CanCollide = false
end
resetDropperAttributesandButton()
end
end)