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

How do i make it so when you collect alot of items u get awarded a badge?

Asked by
notfenv 171
5 years ago
Edited 5 years ago

So, i'm wondering how to make it, well you know in the title. Basically someone clicks a shell and the shell gets deleted so it acts like it got collected.

This is the click to delete script.

function onClicked()
script.Parent:remove()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Below is the badge script. How can i make it award at 10 items?

print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)



-- ROBLOX scripter hackers, see what you can do with this:
-- game:GetService("BadgeService"):UserHasBadge(userid, badgeid)


function OnTouch(part)
    if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
        local p = game.Players:GetPlayerFromCharacter(part.Parent)
        if (p ~= nil) then
            print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
            local b = game:GetService("BadgeService")
            b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
        end
    end
end

script.Parent.Touched:connect(OnTouch)

Also i just signed up.

0
Create an Int variable, when the item is "deleted" or "collected" add 1 to it, in the badge script check when that variable changes, and once its at 10 award badge. DinozCreates 1070 — 5y
0
Could you post an example? notfenv 171 — 5y
0
First, you have this badge in a touched script, does it need to be? DinozCreates 1070 — 5y
0
Well you click the shells and it disappears and that stands out as you collected it. notfenv 171 — 5y
View all comments (5 more)
0
Im gonna take that as a no. DinozCreates 1070 — 5y
0
Could you like post something in answers or idk, Btw the shells are called "ShotgunShells" notfenv 171 — 5y
0
There seems to be a red underline at the onClicked, line 4. notfenv 171 — 5y
0
Well it seems alright now. local db = false local Collected = "Collected" -- you'll need to add in an IntValue somewhere, if you have a leaderstats script you can use that to add the "Collected" value to the player then reference it here function onClicked() if not db then -- I added a DB but may not be needed, but just in case. db = true Collected.Value = Collected.Value + 1 notfenv 171 — 5y
0
Doesn't seem to be working, i'm confused with the Collected =. notfenv 171 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Alright so im doing this in the editor but this should work ok. When you click the shell or whatever it adds 1 to the int value, wherever that ends up. Once you have 10 the badge script will award it once, then once its awarded the nobadge variable should stop it from continuing to try to.

"Click to delete" script.

local db = false
local Collected = -- you'll need to add in an IntValue somewhere, if you have a leaderstats script you can use that to add the "Collected" value to the player then reference it here

function onClicked()
    if not db then -- I added a DB but may not be needed, but just in case. 
        db = true
        Collected.Value = Collected.Value + 1 -- we add 1 to value
        script.Parent:remove()
        wait(.25)
        db = false
    end
end

script.Parent.ClickDetector.MouseClick:Connect(onClicked)

Badge script

local Collected = -- again reference that int value we're making
local nobadge = true

Collected.Changed:Connect(function(player)
    if Collected.Value >= 10 and nobadge then 
        nobadge = false
        print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. player.userId)
        local b = game:GetService("BadgeService")
        b:AwardBadge(player.userId, script.Parent.BadgeID.Value)
    end
end)
Ad

Answer this question