so im trying to make a coin that only one player can see that and get the coin and other players have the same
This is the easiest method, there are other methods, though.
Have a localscript place the coin in workspace
or workspace.CurrentCamera
.
Whomever owns the localscript will see the coin.
This is because localscripts are client sided, that said, if a localscript places a part in workspace, and assuming no other player has the same script, the only player(s) who would see it would be the only player(s) to own the localscript.
By "own", I mean the localscript is inside the player's character, playergui, or backpack.
For this, make a LocalScript and put it in StarterGui.
01 | local coin = game.Workspace.coin --replace this with where the coin is |
02 | local collectsfx = game.ReplicatedStorage.coinsound --this is optional |
03 | local debunk = false |
04 |
05 | coin.Touched:connect( function (hit) |
06 | if game.Players:FindFirstChild(hit.Parent.Name) and coin.Transparency = = 0 and debunk = = false then |
07 | debunk = true |
08 | collectsfx:Play() |
09 | print ( "coin collected" ) |
10 | local plr = game.Players:FindFirstChild(hit.Parent.Name) |
11 | repeat |
12 | coin.Transparency = coin.Transparency+ 0.05 |
13 | wait( 0.05 ) |
14 | until coin.Transparency = = 1 |
15 | coin.CanCollide = false |
16 | --any extra code below (eg giving the player a +coin value |
17 | end |
18 | end ) |