Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

PP getting stacked up?

Asked by 10 years ago

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)

0
No one? Blueguy195 0 — 10y
0
Help!! Blueguy195 0 — 10y
0
helphelphelphelphelphelphelphelphelphelphelp!!!!!!!!!!!!!!!!!! Blueguy195 0 — 10y
0
What is wrong here? Could you elaborate further? MrFlimsy 345 — 10y
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. Blueguy195 0 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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... 
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. Blueguy195 0 — 10y
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? fahmisack123 385 — 10y
0
Thanks Blueguy195 0 — 10y
0
It works?? wow. I didn't expect that... fahmisack123 385 — 10y
View all comments (3 more)
0
It doesn't Blueguy195 0 — 10y
0
Help Blueguy195 0 — 10y
0
... I'll fix it soon. PM me, fahmisack123 and I'll give you the fixed script on Thursday. fahmisack123 385 — 10y
Ad

Answer this question