I need help with making a local coin system

so I have been trying to make a coin that will disappear after it is touched by the player but I want it to disappear only for that player, so a local script, the problem is I can’t use .touched with a local script so I need help finding a way to make the coin work,

thanks in advance to anyone who helps.

Yes, you can. If you’re using the LocalScript on the Workspace it will not run, just declare the Part in a variable and use the LocalScript on StarterPlayer > StarterPlayerScripts
image

I just tested it with a friend and the part disappeared for the both of us, do you think you can give us a example so I know if I did anything wrong? please make sure it only disappears client side

It works fine for me, if you’re doing this make sure to disable the server-sided script and just one should touch the part.
image
image

local RS = game:GetService("ReplicatedStorage")
local Part = workspace.Part

Part.Touched:Connect(function()
	Part.Parent = RS
end)
1 Like

thank you it worked, you just saved us a lot of time.

Quick addon to this, considering using debounce here so that your script is not firing every time the Touched event is fired. This means that it will only trigger once per however often you choose.

1 Like

sorry to bother you again but how can I make the script work on multiple coins?

The most optimal way is to create a folder with all your coins and loop through them.

local RS = game:GetService("ReplicatedStorage")
local PartsFolder = workspace.Parts

for _, obj in ipairs(PartsFolder:GetChildren()) do
	obj.Touched:Connect(function()
		obj.Parent = RS
	end)
end

image

it worked but now it acts as it is a server script and disappears for the both of us

Again, that’s not possible, LocalScripts can’t access the server.
image
image

https://gyazo.com/2633e0a4bf47f9c23870a4ae4c018c13

as you can see it does not work and it is 100% in a local script

What they are trying to say is, they only want the coins to be picked up on the client, they don’t want that to replicate to the server.

2 Likes