Why is my script not working?

Hello!
I want to make a script that kicks the player and gives a badge but its not working can anyone tell me what the problem is?

Its a local script and its in StarterGUI

local player = game.Players.LocalPlayer
local Open = workspace.Part
local opened = false
local BadgeService = game:GetService("BadgeService")
local id = 2141298210 
Open.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		wait(2)
		script.Parent.ScreenGui.Frame.Visible = true
		game.Workspace["Fire sound"]:Stop()
		game.Workspace.Static:Play()
		wait(8)
		script.Parent.ScreenGui.Frame.Label.Image = "rbxassetid://12552596648"	
		wait(0.5)
		script.Parent.ScreenGui.Frame.Label.Image = "rbxassetid://12552673778"
		wait(0.1)
		script.Parent.ScreenGui.Frame.Label.Image = "rbxassetid://12552596648"	
		wait(0.1)
		script.Parent.ScreenGui.Frame.Label.Image = "rbxassetid://12552673778"
		wait(0.1)
		script.Parent.ScreenGui.Frame.Label.Image = "rbxassetid://12552596648"	
		wait(0.1)
		script.Parent.ScreenGui.Frame.Label.Image = "rbxassetid://12552673778"
		if not BadgeService:UserHasBadgeAsync(player.UserId, id) then
			BadgeService:AwardBage(player.UserId, id)
			wait(0.1)
			player:Kick("???")
		end
	end
end)

Does it give a badge, does the image change? I think you might need to use remote events for badges. P.S don’t use wait(), instead use task.wait() because wait() is deprecated.

For example make a remoteevent in replicated storage, and make a script in scriptservice. Put in this localscript remoteevent:FireServer() and on the other script ``

remoteevent.OnServerEvent:Connect(function()
if not BadgeService:UserHasBadgeAsync(player.UserId, id) then
			BadgeService:AwardBage(player.UserId, id)
end
end)
1 Like

The image changing is not the problem it doesn’t give the badge and kick the player but i will try it with remote events

Oh i just edited my message and gave an example. Hope it helps!

There’s a typo in the line BadgeService:AwardBage(player.UserId, id) , “Bage” should be “Badge”.

1 Like

does it not give an error if it were to be type like that

3 Likes

From my experience, there were moments where my scripts had errors but it wouldn’t show up in the output tab.
It could also be the same case for this one although I find it weird how it wouldn’t

2 Likes

The player now gets kicked but the badge awarding still doesn’t work even with remote events

whats the script on local AND server

You can only award badges on the server.

2 Likes

This problem seems very similar to a problem another fellow had a few days ago (which i tried to help with)

the badge giving ended up working OUTSIDE of the game, as in, in the actual game instead of roblox studio. you should read the whole post to see if it helps.

oh nvm someone solved it lol

Turns out i had 2 typos thanks for the help:)

Yes. You should always do what the script wants you to do even if theres no errors. errors dont matter. Its spelling that matters.

Glad a post I made helped another person, well might have helped if this was already solved.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.