-
What do you want to achieve?
I want to display the top three players’ characters on a podium in game, but the players’ characters are not showing up properly. -
What is the issue?
Currently, I have dummies positioned on the podium, and I am using code to replace the dummies with the players’ outfits. However, the size of the players’ characters remains the same as their actual size, instead of resizing to match the size of the dummies.
My code:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- variables to set up player name (that are going to be used later on the script, to change dummies appearance)
local plrName1 = script.Parent["#1"].Nickname.Text
local plrName2 = script.Parent["#2"].Nickname.Text
local plrName3 = script.Parent["#3"].Nickname.Text
print("Initial player names:")
print(plrName1)
print(plrName2)
print(plrName3)
-- variables to set up leaderboard
local leaderboard = script.Parent.Parent.Parent.Parent
-- variables of statues of where the dummies are standing on
local top1 = leaderboard.Statues.Top1
local top2 = leaderboard.Statues.Top2
local top3 = leaderboard.Statues.Top3
-- dummies
local playertop1 = top1.NumberOne
local playertop2 = top2.NumberTwo
local playertop3 = top3.NumberThree
-- create the BindableEvent and set it's parent to ReplicatedStorage
local myEvent = Instance.new("BindableEvent", ReplicatedStorage)
-- function to change the rig of a player's character
local function changeRig(dummyRig, player)
local description = Players:GetHumanoidDescriptionFromUserId(player.UserId)
dummyRig.Humanoid:ApplyDescription(description)
end
-- update the dummies when the player names change
local function updateDummies()
-- update player names
plrName1 = script.Parent["#1"].Nickname.Text
plrName2 = script.Parent["#2"].Nickname.Text
plrName3 = script.Parent["#3"].Nickname.Text
print("Updated player names:")
print(plrName1)
print(plrName2)
print(plrName3)
-- update the dummies
local player1 = Players:FindFirstChild(plrName1)
local player2 = Players:FindFirstChild(plrName2)
local player3 = Players:FindFirstChild(plrName3)
if player1 then
changeRig(playertop1, player1)
end
if player2 then
changeRig(playertop2, player2)
end
if player3 then
changeRig(playertop3, player3)
end
end
-- set up event listeners for player name changes
script.Parent["#1"].Nickname.Changed:Connect(function()
task.wait(1)
print("Nickname for player #1 changed to: " .. script.Parent["#1"].Nickname.Text)
updateDummies()
end)
script.Parent["#2"].Nickname.Changed:Connect(function()
task.wait(1)
print("Nickname for player #2 changed to: " .. script.Parent["#2"].Nickname.Text)
updateDummies()
end)
script.Parent["#3"].Nickname.Changed:Connect(function()
task.wait(1)
print("Nickname for player #3 changed to: " .. script.Parent["#3"].Nickname.Text)
updateDummies()
end)
while true do
task.wait(5)
updateDummies()
end