How to make a collectable coin in Roblox Studio!
In todays video, I show you how to make a collectable coin for your Roblox game! enjoy (:
coin script:
----------------------------------------------------
local stat = "Coins"
local respawnTime = 30
script.Parent.Touched:Connect(function(hit)
if script.Parent.Transparency == 1 then return end
script.Parent.Transparency = 1
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if not player then script.Parent.Transparency = 0 return end
player:WaitForChild("leaderstats"):WaitForChild(stat).Value += 1
wait(respawnTime)
script.Parent.Transparency = 0
end)
------------------------------------------------------
leaderstat script:
------------------------------------------------------
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coin = Instance.new("IntValue")
Coin.Name = "Text Here" -- Change this to what you want the leaderstat name to be
Coin.Value = 0
Coin.Parent = leaderstats
end)
--------------------------------------------------------
tags: #roblox #robloxstudio #tutorial #gaming #education #educational #trending #robloxstudiotutorials #new #viralvideo #coin