I'm new to programming, and I was wondering how I can separate variables inside models (like IntValue and StringValue) when duplicating. In my game, there's a booth that contains OwnerName and OwnerId. You are able to re-name and abandon the booth using remote events. However, I run into this problem when I duplicate a booth because when I claim one booth (through mouseclick), the OwnerName and OwnerId for the other one also changes. I was able to make the booths change text asynchronously by checking if (player.UserId == Booth.OwnerId). I'm also able to abandon the booths by looping through all the booths and figuring out if the UserId and OwnerId match up. However, I just can't seem to figure out how to separate the two variables when claiming a booth. Please help.
-- LaunchBoothPressed Script -- local CollectionService = game:GetService("CollectionService") local ClickDetector = script.Parent.ClickDetector local ownerId = script.Parent.Parent.OwnerId local ownerName = script.Parent.Parent.OwnerName ClickDetector.MouseClick:Connect(function(player) if (ownerId.Value == 0) then ownerId.Value = player.UserId ownerName.Value = player.Name end for i, v in pairs(CollectionService:GetTagged("Booths")) do if (v.OwnerId.Value == player.UserId) then end end if (ownerId.Value == player.UserId) then game.ReplicatedStorage.BoothPressed:FireClient(player) else game.ReplicatedStorage.BoothUnavailable:FireClient(player) end end) -- ResetBooth -- local CollectionService = game:GetService("CollectionService") local Players = game:GetService("Players") game.ReplicatedStorage.AbandonPressed.OnServerEvent:Connect(function(player) for i, v in pairs(CollectionService:GetTagged("Booths")) do if (v.OwnerId.Value == player.UserId) then v.OwnerId.Value = 0 v.OwnerName.Value = "" v.Sign.BoothName.Label.Text = "Click here to rent this booth." end end end) Players.PlayerRemoving:Connect(function(player) for i, v in pairs(CollectionService:GetTagged("Booths")) do if (v.OwnerId.Value == player.UserId) then v.OwnerId.Value = 0 v.OwnerName.Value = "" v.Sign.BoothName.Label.Text = "Click here to rent this booth." end end end) -- UpdateText -- game.ReplicatedStorage.EnterPressed.OnServerEvent:Connect(function(player, input) if (script.Parent.Parent.OwnerId.Value == player.UserId) then script.Parent.BoothName.Label.Text = input end end)
Ok, problem was solved by putting a boolean value for if player is owner in starter gui.