I'm trying to make it so when you touch a gold coin you'll get 25 points/coins. But it only works on studio. Help me please, also give me tips with scripting things for studio and outside of studio.
children = game.Workspace.Coins:GetChildren() while true do for _, child in ipairs(children) do if child.Name == "GoldCoin" then child.Touched:connect(function(Touched) local p = Touched.Parent:FindFirstChild("Humanoid") if p ~= nil then local player = game.Players:GetPlayerFromCharacter(Touched.Parent) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 25 Sound = script.CoinSound:Clone() Sound.Parent = child Sound:Play() game.Debris:AddItem(Sound, 7) child:remove() end end) end end wait() end