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

Trying to award a badge, but can't reference userId?

Asked by
corbenv 17
4 years ago

How do I reference userId????

sorry, It's a really long script but it does something specific. problem is on line 5/10

local badgeID = 2124476391
local bs = game:GetService("BadgeService")
local userId = Player.userId
local Knock = script.Parent.Knock
local a = script.Parent

while true do
    wait(math.random(10,15))
    Knock:Play()
    bs:AwardBadge(userId,badgeID)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(.05)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.5
    wait(.05)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(1.9)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.3
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 0.6
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 1
    wait(.4)
    a.Material = "SmoothPlastic"
    wait(.05)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.5
    wait(.05)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(1.5)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.3
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 0.6
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 1
    wait(.5)
    a.Material = "SmoothPlastic"
    wait(.05)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.5
    wait(.05)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(1.4)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.3
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 0.6
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 1
end
0
This script lacks tonnes of stuff, what are you trying to do? MachoPiggies 526 — 4y
0
I'm trying to give a badge, ignore every line but 1, 2, 3, and 10. Those are the only ones that relate to the problem corbenv 17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You just didn't put Player as a variable... I don't know if you're trying to do a touched or something but if it is a player joined then do

game.Players.PlayerAdded:Connect(function(Player)
local badgeID = 2124476391
local bs = game:GetService("BadgeService")
local userId = Player.userId
local Knock = script.Parent.Knock
local a = script.Parent

while true do
    wait(math.random(10,15))
    Knock:Play()
    bs:AwardBadge(userId,badgeID)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(.05)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.5
    wait(.05)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(1.9)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.3
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 0.6
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 1
    wait(.4)
    a.Material = "SmoothPlastic"
    wait(.05)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.5
    wait(.05)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(1.5)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.3
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 0.6
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 1
    wait(.5)
    a.Material = "SmoothPlastic"
    wait(.05)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.5
    wait(.05)
    a.Material = "SmoothPlastic"
    script.Parent.SurfaceLight.Brightness = 0
    wait(1.4)
    a.Material = "Neon"
    script.Parent.SurfaceLight.Brightness = 0.3
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 0.6
    wait(.1)
    script.Parent.SurfaceLight.Brightness = 1
end
end)

And if you're not doing a player added, then set a player

0
this script is an event that happens every 10 - 15 seconds, and I want every player to receive the badge when this script goes off. What would I set Player as? Like in a local value? I tried game.Players.LocalPlayer but that still didn't work corbenv 17 — 4y
Ad

Answer this question