Why isn't my PlayerGui working as intended?
Asked by
4 years ago Edited 4 years ago
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.
- the script is in StarterGui but it is being called in PlayerGui
- the coins are meshes in the workspace
If anyone knows my problem and knows how to fix it, please do explain. Thank you.
001 | local coinTrack 1 = true |
002 | local coinTrack 2 = true |
003 | local coinTrack 3 = true |
004 | local coinTrack 4 = true |
005 | local coinTrack 5 = true |
006 | local coinTrack 6 = true |
007 | local coinTrack 7 = true |
010 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
011 | game.Workspace.RedCoin 1. Touched:Connect( function (hit) |
012 | if coinTrack 1 = = true then |
013 | if hit.Parent:WaitForChild( "Humanoid" ) then |
014 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
015 | coinNum = coinNum + 1 |
016 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
017 | game.Workspace.RedCoin 1. Transparency = . 7 |
027 | game.Workspace.RedCoin 2. Touched:Connect( function (hit) |
028 | if coinTrack 2 = = true then |
029 | if hit.Parent:WaitForChild( "Humanoid" ) then |
030 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
031 | coinNum = coinNum + 1 |
032 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
033 | game.Workspace.RedCoin 2. Transparency = . 7 |
043 | game.Workspace.RedCoin 3. Touched:Connect( function (hit) |
044 | if coinTrack 3 = = true then |
045 | if hit.Parent:WaitForChild( "Humanoid" ) then |
046 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
047 | coinNum = coinNum + 1 |
048 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
049 | game.Workspace.RedCoin 3. Transparency = . 7 |
059 | game.Workspace.RedCoin 4. Touched:Connect( function (hit) |
060 | if coinTrack 4 = = true then |
061 | if hit.Parent:WaitForChild( "Humanoid" ) then |
062 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
063 | coinNum = coinNum + 1 |
064 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
065 | game.Workspace.RedCoin 4. Transparency = . 7 |
075 | game.Workspace.RedCoin 5. Touched:Connect( function (hit) |
076 | if coinTrack 5 = = true then |
077 | if hit.Parent:WaitForChild( "Humanoid" ) then |
078 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
079 | coinNum = coinNum + 1 |
080 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
081 | game.Workspace.RedCoin 5. Transparency = . 7 |
091 | game.Workspace.RedCoin 6. Touched:Connect( function (hit) |
092 | if coinTrack 6 = = true then |
093 | if hit.Parent:WaitForChild( "Humanoid" ) then |
094 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
095 | coinNum = coinNum + 1 |
096 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
097 | game.Workspace.RedCoin 6. Transparency = . 7 |
107 | game.Workspace.RedCoin 7. Touched:Connect( function (hit) |
108 | if coinTrack 7 = = true then |
109 | if hit.Parent:WaitForChild( "Humanoid" ) then |
110 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
111 | coinNum = coinNum + 1 |
112 | player.PlayerGui.CoinTracker.Frame.TextLabel.Text = "Coins " ..coinNum.. "/7" |
113 | game.Workspace.RedCoin 7. Transparency = . 7 |