So I wrote this script that allows a player to find/collect special coins, and when they do, the coins become semi-transparent, signifying to the player collecting that they already collected this coin and they cannot collect it again. It then adds the found coin to a coin count in a gui at the bottom left corner (It allows them to go from 1/7, 2/7...7/7 kind of like in slender when you need to collect all 7 pages). I have it set under the PlayerGui, however, everyone's gui changes with the person who collects the coins. Instead, I'd like everyone's Coin count in the gui to remain at 0 and the coins to remain opaque until the players collect the coins themselves.
Also, once a player resets, the coins collected remain transparent for all players, but the coin counter resets and goes back to 0, which is not acceptable.
If anyone knows my problem and knows how to fix it, please do explain. Thank you.
local coinTrack1 = true local coinTrack2 = true local coinTrack3 = true local coinTrack4 = true local coinTrack5 = true local coinTrack6 = true local coinTrack7 = true local coinNum = 0 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin1.Touched:Connect(function(hit) if coinTrack1 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin1.Transparency = .7 coinTrack1 = false return coinNum end end end) game.Workspace.RedCoin2.Touched:Connect(function(hit) if coinTrack2 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin2.Transparency = .7 coinTrack2 = false return coinNum end end end) game.Workspace.RedCoin3.Touched:Connect(function(hit) if coinTrack3 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin3.Transparency = .7 coinTrack3 = false return coinNum end end end) game.Workspace.RedCoin4.Touched:Connect(function(hit) if coinTrack4 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin4.Transparency = .7 coinTrack4 = false return coinNum end end end) game.Workspace.RedCoin5.Touched:Connect(function(hit) if coinTrack5 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin5.Transparency = .7 coinTrack5 = false return coinNum end end end) game.Workspace.RedCoin6.Touched:Connect(function(hit) if coinTrack6 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin6.Transparency = .7 coinTrack6 = false return coinNum end end end) game.Workspace.RedCoin7.Touched:Connect(function(hit) if coinTrack7 == true then if hit.Parent:WaitForChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin7.Transparency = .7 coinTrack7 = false return coinNum end end end)
I think it's because you are detecting if someone touches the coin and making it so that it changes for everyone so instead you could get the player name that touched the coin and make it specifically so that it changes only for them. You did
local player = game.Players.LocalPlayer player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin1.Touched:Connect(function(hit) if coinTrack1 == true then if hit.Parent:WaitForChild("Humanoid") then coinNum = coinNum + 1 player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins "..coinNum.."/7" game.Workspace.RedCoin1.Transparency = .7 return coinNum
where as you need to take hit
and get the name of the player that hit it from there and change their Gui
I might be wrong but that's all I've got