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

PP getting stacked up?

When I play my game all the PP gets stacked up and never deletes. How do you fix it? I have the script inside a brick and when you touch it, it gives you 3 player points.

local PointsService = game:GetService("PointsService")

local db = false local dbTime = 3

function onTouched(hit) if not hit.Parent:FindFirstChild("Humanoid") or db then return end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then db = true PointsService:AwardPoints(player.userId, 3) wait() wait(2) script.Parent:Destroy() db = false end end

script.Parent.Touched:connect(onTouched)

5 comments

0

No one?

0

Help!!

0

helphelphelphelphelphelphelphelphelphelphelp!!!!!!!!!!!!!!!!!!

0

What is wrong here? Could you elaborate further?

0

I want the brick in lighting called "PP" to be cloned and spawned randomly across the map and when they are touched, they are destroyed but not away. But if they're still on the ground and someone touches it they are given 3 player points. But since this is the script inside PP I just want it to give PP when touched by a player and destroyed after 2 seconds of being touched.

1 answer

if you want a part that gives 3 player points, put this in the part (NORMAL SCRIPT)

debounce = true
script.Parent.Touched:connect(function(hit) --Part gets touched, we call the toucher "hit"
	player = hit.Parent:FindFirstChild("Humanoid") --Checks for Player
	if player ~= nil and debounce==true then --There must be a Humanoid and debounce must be true. Then do...
		debounce == false --Avoids a continuous repeat
		game:GetService("PointsService"):AwardPoints(hit.userId, 3) --Awards 3 Points to toucher
	else --If it's not a player then...
		script.Parent:Destroy() --Completely remove the brick
	end 
	wait(10) --Change this 10(seconds) to whatever you want(Seconds)
	debounce = true --The part can be touched again.
end
--This should work, as long as it's in a NORMAL SCRIPT. Remember to clone it... 

7 comments

0

The brick is going to be raining from the sky. So I want it to be destroyed 2 seconds after it touches something but it still awards points if it's a player.

0

Now what it should do is: if it touches a player, the player gets 3 PP's, if not, the brick gets deleted instantly. If you think that I have helped you, please consider giving this the right answer?

0

Thanks

0

It works?? wow. I didn't expect that...

0

It doesn't

0

Help

0

... I'll fix it soon. PM me, fahmisack123 and I'll give you the fixed script on Thursday.

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