Hi all developers, i have a problem for my gui.
When i load the game all things are perfect(like gui, scripts) but i figured out that when i touch a duck that i don’t have it gives me the badge but the gui doesn’t update. I’m a beginner in scripting so i tried some scripts but nono of them works.
This is the local script in the GUI:
local Ducks = require(game:GetService("ReplicatedStorage").DucksUIHandler.Ducks)
local BadgeService = game:GetService("BadgeService")
for _, duck in ipairs(Ducks) do
local duckFrame =game.ReplicatedStorage.DucksUIHandler.Template:Clone()
duckFrame.Parent = script.Parent.Frame.Container
duckFrame.Name = duck.ID
duckFrame.ImageLabel.Image = "rbxthumb://type=Asset&id="..duck.imageID.."&w=420&h=420"
if duck.difficulty == "EASY" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(25,191,0)
elseif duck.difficulty == "MEDIUM" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(255,170,0)
elseif duck.difficulty == "HARD" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(170,0,0)
elseif duck.difficulty == "MYTHICHAL" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(255,0,255)
elseif duck.difficulty == "LIMITED" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(255,255,255)
elseif duck.difficulty == "EXCLUSIVE" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(170, 85, 255)
elseif duck.difficulty == "SOON" then
duckFrame.DifficultyLabel.Text = duck.difficulty
duckFrame.DifficultyLabel.BackgroundColor3 = Color3.fromRGB(0,0,0)
duckFrame.DifficultyLabel.TextColor = BrickColor.new("White")
end
duckFrame.Namef.Text = duck.name
if BadgeService:UserHasBadgeAsync(game.Players.LocalPlayer.UserId, duck.badgeID) then
duckFrame.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
else
duckFrame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
end
end
This is the script in every duck:
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
game:GetService("BadgeService"):AwardBadge(player.UserId, 2129410072)
end
end)
Also i have a Module script where all duck names, id, badgeId, ImageId, Id are, this is 1 duck:
{
ID = "NormalDuck",
name = "Normal Duck",
difficulty = "EASY",
badgeID = 2129399897,
imageID = 11552766665,
},
Is it possible create one single script in ServerScriptService(Server Event) and put 1 script to all models like Firing the badge id or name to change the background of the ducks UI?
This is the image, the images in the frames are white because i didn’t put the images for now.
Thanks!
