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

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

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

2 comments

0

This script lacks tonnes of stuff, what are you trying to do?

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

1 answer

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

1 comment

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

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