How to make that if so me o n e to u che s the ro o f the n i t g i v e s c o i n s? P l e a s e h e l p.
Scripts: (all in s e r v e r s c r i p t s e r v i c e) local DataStoreService = game:GetService("DataStoreService") local CoinsStore = DataStoreService:GetDataStore("CoinsStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder") --making leaderstats leaderstats.Name = "leaderstats" leaderstats.Parent = player local Coins = Instance.new("IntValue") --making coins Coins.Name = "Coins" Coins.Parent = leaderstats local UserId = player.UserId local data local success, errormessage = pcall(function() --getting loaded data data = CoinsStore:GetAsync(UserId) end) if success then Coins.Value = data end
end)
game.Players.PlayerRemoving:Connect(function(player) local UserId = player.UserId local data = player.leaderstats.Coins.Value
CoinsStore:SetAsync(UserId, data)
end)
local roof = game.Workspace.Roof --wherever roof is for you local debounce = false local reset_seconds = 1 roof.Touched:Connect(function(hit) --when roof is touched if hit.Parent:FindFirstChild("Humanoid") and debounce == false then --checks if its player debounce = true local player = game.Players[hit.Parent.Name] --gets player player.leaderstats.Coins += --whatever amount you want --gives coins wait(reset_seconds) debounce = false end end)
well you can do this
this basically checks if its player that touched roof and then gives coins, have not tested code, sorry if there are errors.