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

Unknown global 'player' in a local script?

Asked by
corbenv 17
4 years ago
Edited 4 years ago

I'm trying to give a badge every time this function fires. I have one script and one localscript. It does not give me any indication of anything happening. I've been trying to fix this for a week now and I've practically given up.

Here is the script:

local Knock = script.Parent.Knock
local a = script.Parent
local knockbadgeEvent = game.ServerStorage.knockbadge

while true do
    wait(math.random(5,6))
    knockbadgeEvent:FireAllClients()
    Knock:Play()
    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

And here is the localscript:

local badgeID = 2124476391
local bs = game:GetService("BadgeService")

local function onknockbadgeFired()
    bs:AwardBadge(player.UserId, badgeID)
end

I've tried defining player as game.Players.LocalPlayer but that doesn't work either!

0
i dont see where the issue lies, how about showing the whole script(s) jesusbeef 33 — 4y
0
k, but it's 58~ lines long lol corbenv 17 — 4y
0
On line 1 type "repeat wait() until game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")" greatneil80 2647 — 4y

1 answer

Log in to vote
0
Answered by
herrtt 387 Moderation Voter
4 years ago
local player = game:GetService("Players").LocalPlayer

Add this to the LocalScript and player should then be defined.

0
I did that and now it is defined, but the badge is still not being given out. corbenv 17 — 4y
Ad

Answer this question