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
6 years ago
Edited 6 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.

1function onClicked()
2script.Parent:remove()
3end
4script.Parent.ClickDetector.MouseClick:connect(onClicked)

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

01print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)
02 
03 
04 
05-- ROBLOX scripter hackers, see what you can do with this:
06-- game:GetService("BadgeService"):UserHasBadge(userid, badgeid)
07 
08 
09function OnTouch(part)
10    if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
11        local p = game.Players:GetPlayerFromCharacter(part.Parent)
12        if (p ~= nil) then
13            print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
14            local b = game:GetService("BadgeService")
15            b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
16        end
17    end
18end
19 
20script.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 — 6y
0
Could you post an example? notfenv 171 — 6y
0
First, you have this badge in a touched script, does it need to be? DinozCreates 1070 — 6y
0
Well you click the shells and it disappears and that stands out as you collected it. notfenv 171 — 6y
View all comments (5 more)
0
Im gonna take that as a no. DinozCreates 1070 — 6y
0
Could you like post something in answers or idk, Btw the shells are called "ShotgunShells" notfenv 171 — 6y
0
There seems to be a red underline at the onClicked, line 4. notfenv 171 — 6y
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 — 6y
0
Doesn't seem to be working, i'm confused with the Collected =. notfenv 171 — 6y

1 answer

Log in to vote
0
Answered by 6 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.

01local db = false
02local 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
03 
04function onClicked()
05    if not db then -- I added a DB but may not be needed, but just in case.
06        db = true
07        Collected.Value = Collected.Value + 1 -- we add 1 to value
08        script.Parent:remove()
09        wait(.25)
10        db = false
11    end
12end
13 
14script.Parent.ClickDetector.MouseClick:Connect(onClicked)

Badge script

01local Collected = -- again reference that int value we're making
02local nobadge = true
03 
04Collected.Changed:Connect(function(player)
05    if Collected.Value >= 10 and nobadge then
06        nobadge = false
07        print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. player.userId)
08        local b = game:GetService("BadgeService")
09        b:AwardBadge(player.userId, script.Parent.BadgeID.Value)
10    end
11end)
Ad

Answer this question