Spawning script: (server)
local coin = game.ReplicatedStorage.Coin
while true do
local coinWorkspace = coin:Clone()
coinWorkspace.Parent = workspace
coinWorkspace.Position = Vector3.new(math.random(-100, 100), 5, math.random(-100, 100))
game.Debris:AddItem(coinWorkspace, 5)
task.wait(1)
end
Leaderstats script: (local)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local leaderstats = Instance.new("Folder")
leaderstats.Parent = player
leaderstats.Name = "leaderstats"
local coins = Instance.new("IntValue")
coins.Parent = leaderstats
coins.Name = "Coins"
Collection script inside of the spawned coin: (local)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local coin = script.Parent
local leaderstats = player:WaitForChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
coin.Touched:Connect(function()
coins.Value += 1
coin:Destroy()
end)
Summary: The first script is suppose to spawn coins from replicated storage at a random place on the map (which works), the second creates leaderstats and a Coins IntValue within that (which also works), and inside of the cloned coins there are LocalScripts that are meant to wait for the leaderstats in the local player then the coins inside them, and when the coin is touched the value goes up, but this does not work.
** You are now Level 4! **