Hello, I have an error in my script, when I press the buttons, pressing Time would give me 9 scripts and pressing GiveTool would give me none
I need them to give 1 each
local squip = Instance.new("Script")
squip.Source = [[--Instructions, replace 1 with your own badge ID
local badgeID = 0
local badgeService = game:GetService("BadgeService")
game.Players.PlayerAdded:Connect(function(player)
wait(1)
if not badgeService:UserHasBadge(player.UserId, badgeID) then
badgeService:AwardBadge(player.UserId, badgeID)
end
end)
]]
squip.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Time.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip2 = Instance.new("Script")
squip2.Source = [[--Instructions, replace 0 with your own badge ID and change time to whatever you want, it`s in seconds
local badgeID = 0
local badgeService = game:GetService("BadgeService")
game.Players.PlayerAdded:Connect(function(player)
wait(600)
if not badgeService:UserHasBadge(player.UserId, badgeID) then
badgeService:AwardBadge(player.UserId, badgeID)
end
end)
]]
squip2.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Touch.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip3 = Instance.new("Script")
squip3.Source = [[--Instructions, replace 0 with your own badge ID and place this into a part
local badgeservice = game:GetService("BadgeService")
local id = 0
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeservice:AwardBadge(plr.UserId, id)
end
end)
]]
squip3.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Leaderstats.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip4 = Instance.new("Script")
squip4.Source = [[--Instructions, replace 0 with your own badge ID, change 100 to whatever amount you need and change Coins to your leaderstat value
local BadgeService = game:GetService("BadgeService")
local BadgeID = 0
local AmountNeeded = 100
game.Players.PlayerAdded:Connect(function(Player)
Player.leaderstats.Coins.Changed:Connect(function()
if Player.leaderstats.Coins.Value >= AmountNeeded then
BadgeService:AwardBadge(Player.UserId, BadgeID)
end
end)
end)
]]
squip4.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Meet.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip5 = Instance.new("Script")
squip5.Source = [[--Instructions, replace 0 with your own badge ID and replace Username with your own username
local BadgeID = 0
game.Players.PlayerAdded:Connect(function(Player)
if game.Players:FindFirstChild("Username") then
for i, players in pairs(game.Players:GetPlayers())do
game.BadgeService:AwardBadge(players.UserId, BadgeID)
end
end
end)
]]
squip5.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.GiveTool.MouseButton1Click:connect(function()
local squip6 = Instance.new("Script")
squip6.Source = [[--Instructions, replace 0 with your own badge ID then put a tool in ReplicatedStorage and replace :WaitForChild("Tool") with :WaitForChild("the tool name")
local BadgeService = game:GetService("BadgeService")
local Tool = game:GetService("ReplicatedStorage"):WaitForChild("Tool")
local BadgeId = 0
game.Players.PlayerAdded:Connect(function(player)
if BadgeService:UserHasBadgeAsync(player.UserId,BadgeId) then
Tool:Clone().Parent = player.Backpack
Tool:Clone().Parent = player.StarterGear
end
end)
]]
squip6.Parent = game.Workspace
end)
end)
end)
end)
end)
end)
else
game.CoreGui:WaitForChild("UI").Parent = script -- hides the UI
end
end)
Its kind of long, but I cannot seem to find the error myself
local squip = Instance.new("Script")
squip.Source = [[--Instructions, replace 1 with your own badge ID
local badgeID = 0
local badgeService = game:GetService("BadgeService")
game.Players.PlayerAdded:Connect(function(player)
wait(1)
if not badgeService:UserHasBadge(player.UserId, badgeID) then
badgeService:AwardBadge(player.UserId, badgeID)
end
end)
]]
squip.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Time.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip2 = Instance.new("Script")
squip2.Source = [[--Instructions, replace 0 with your own badge ID and change time to whatever you want, it`s in seconds
local badgeID = 0
local badgeService = game:GetService("BadgeService")
game.Players.PlayerAdded:Connect(function(player)
wait(600)
if not badgeService:UserHasBadge(player.UserId, badgeID) then
badgeService:AwardBadge(player.UserId, badgeID)
end
end)
]]
squip2.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Touch.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip3 = Instance.new("Script")
squip3.Source = [[--Instructions, replace 0 with your own badge ID and place this into a part
local badgeservice = game:GetService("BadgeService")
local id = 0
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeservice:AwardBadge(plr.UserId, id)
end
end)
]]
squip3.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Leaderstats.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip4 = Instance.new("Script")
squip4.Source = [[--Instructions, replace 0 with your own badge ID, change 100 to whatever amount you need and change Coins to your leaderstat value
local BadgeService = game:GetService("BadgeService")
local BadgeID = 0
local AmountNeeded = 100
game.Players.PlayerAdded:Connect(function(Player)
Player.leaderstats.Coins.Changed:Connect(function()
if Player.leaderstats.Coins.Value >= AmountNeeded then
BadgeService:AwardBadge(Player.UserId, BadgeID)
end
end)
end)
]]
squip4.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.Meet.MouseButton1Click:connect(function() -- you will have to change Bar.Button to your ui names in the UI.
local squip5 = Instance.new("Script")
squip5.Source = [[--Instructions, replace 0 with your own badge ID and replace Username with your own username
local BadgeID = 0
game.Players.PlayerAdded:Connect(function(Player)
if game.Players:FindFirstChild("Username") then
for i, players in pairs(game.Players:GetPlayers())do
game.BadgeService:AwardBadge(players.UserId, BadgeID)
end
end
end)
]]
squip5.Parent = game.Workspace
game.CoreGui:WaitForChild("UI").ImageLabel.GiveTool.MouseButton1Click:connect(function()
local squip6 = Instance.new("Script")
squip6.Source = [[--Instructions, replace 0 with your own badge ID then put a tool in ReplicatedStorage and replace :WaitForChild("Tool") with :WaitForChild("the tool name")
local BadgeService = game:GetService("BadgeService")
local Tool = game:GetService("ReplicatedStorage"):WaitForChild("Tool")
local BadgeId = 0
game.Players.PlayerAdded:Connect(function(player)
if BadgeService:UserHasBadgeAsync(player.UserId,BadgeId) then
Tool:Clone().Parent = player.Backpack
Tool:Clone().Parent = player.StarterGear
end
end)
]]
squip6.Parent = game.Workspace
end)
end)
end)
end)
end)
end)
else
game.CoreGui:WaitForChild("UI").Parent = script -- hides the UI
end
end)
First, when you try to set the source, you don’t set it to anything. Instead you have things commented out. I did not know if this is a plugin script or meant for a game (before you stated in a reply) as you are trying to change the source of scripts and are using CoreGui, but at the same time are using badge service and player added… I really don’t know how to provide any solution at this point, please improve the code above and make it more readable before anyone can help out.
This should’ve been stated in the topic (as you can see above, I was confused at what was being done at all). I recommend learning about plugin development. The code provided is very unreadable and is nearly impossible to see what’s going on with the comments everywhere and the way it’s formatted.
I’d recommend trying these tutorials to get started: