Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a Point giver When you walk into a block?

I want to have it when i go into a bush or a part it gives me money on leader stats and it disappear for a while and comes back, i cant seem to find any code on how to do Any help will help.

1 answer

✓ Accepted answer

Articles I used to learn how to do this: Leaderboards - https://developer.roblox.com/en-us/articles/Leaderboards OnTouched - https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched

bush = game.Workspace.Bush
isHidden = false 

--Give the player a Points leaderboard when they join the game
game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
 
	local Points = Instance.new("IntValue")
	Points.Parent = leaderstats
	Points.Name = "Points"
	Points.Value = 0
end)


--Fires a function when the player touches the bush
bush.Touched:Connect(function(hit)
	--if the bush is not hidden and the thing touching the bush is a player...
	if(not isHidden and game.Players:FindFirstChild(hit.Parent.Name))then
		--give the player one point and make the brick hidden again
		local player = game.Players[hit.Parent.Name]

		player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1

		bush.Transparency = 1
		bush.CanCollide = false 
		isHidden = true

		wait(2) -- wait 2 seconds to make the bush visible again after being touched

		isHidden = false 
		bush.CanCollide = true
		bush.Transparency = 0
		
	end
end)


This discussion is preserved as it was. New answers, comments, and votes are closed.