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

The Code That I am making is not working and I don't know why?

so I have this code that is suppose to give a badge when the word "/nuke" is said by me, but it doesnt work! Anyone know why? admin = {"VipDanT"}

if admin.Chatted "/nuke" then local badgeservice = game:GetService("BadgeService") local badgeId = 2128480065 local Players = game:GetService("Players")

local function giveBadges(id) -- allows you to call giveBadges (with the ID as the first parameter) to give every player in the server a badge.
	for i, player in pairs(Players:GetPlayers()) do
		badgeservice:AwardBadge(player.UserId , id)
	end
end

giveBadges(badgeId)

end

2 comments

0

did you view the output or the dev console to see any errors that might hint at it?

0

I looked but nothing showed

1 answer

✓ Accepted answer

I took a decent look at that script and it seemed like your attempt to call the "chatted" function was wrong. This is how I usually do it.

admin = {"VipDanT"}
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
	if table.find(admin, plr.Name) then
		if msg == "/nuke" then 
			local badgeservice = game:GetService("BadgeService") 
			local badgeId = 2128480065 
			local Players = game:GetService("Players")
			local function giveBadges(id)
			for i, player in pairs(Players:GetPlayers()) do
				badgeservice:AwardBadge(player.UserId , id)
			end
			end
			giveBadges(badgeId)
		end
	end
	end)
end)

That was the only error I could see in your script. Hopefully this one works out for you!

1 comment

0

Thank you Taxicar24!

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