Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Made by Tweakified, Neonblox Games
- YouTube Tutorial: https://youtu.be/RM6v_fQKx9w
- Discord Support: https://discord.com/invite/JdaFf7p
- Local Script: https://pastebin.com/tQrzBpFk
- Script Type: Regular Script
- Script Parent: ServerScriptService
- --]]
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local GetCoin = ReplicatedStorage:WaitForChild("GetCoin")
- local CoinsFolder = workspace:WaitForChild("Coins")
- local function NewPlayer(player)
- local leaderstats = Instance.new("Folder") -- include this line if you don't have a leaderboard (remove if not)
- local leaderstats = player:WaitForChild("leaderstats") -- include this line if you already have a leaderboard (remove if not)
- leaderstats.Name = "leaderstats"
- local coins = Instance.new("NumberValue", leaderstats)
- coins.Name = "Coins"
- local coindata = Instance.new("Folder")
- coindata.Name = "coindata"
- for _, Coin in pairs(CoinsFolder:GetChildren()) do
- local collectedCoin = Instance.new("BoolValue", coindata)
- collectedCoin.Name = Coin.Name
- end
- leaderstats.Parent = player
- coindata.Parent = player
- end
- Players.PlayerAdded:Connect(NewPlayer)
- for _, player in pairs(Players:GetPlayers()) do
- NewPlayer(player)
- end
- for i, Coin in pairs(CoinsFolder:GetChildren()) do
- Coin.Name = "Coin".. i
- Coin.Touched:Connect(function(hit)
- local char = hit.Parent
- if char ~= nil then
- local player = Players:GetPlayerFromCharacter(char)
- if player ~= nil then
- local leaderstats = player:FindFirstChild("leaderstats")
- local coindata = player:FindFirstChild("coindata")
- if leaderstats ~= nil and coindata ~= nil then
- local CoinValue = leaderstats:FindFirstChild("Coins")
- local CollectedCoin = coindata:FindFirstChild(Coin.Name)
- if CoinValue ~= nil and CollectedCoin ~= nil and CollectedCoin.Value == false then
- CollectedCoin.Value = true
- CoinValue.Value = CoinValue.Value + 1
- GetCoin:FireClient(player, Coin)
- end
- end
- end
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement