hi there, I am having a problem with this script. I had implemented the code and it works great to show the thumbnail. problem is that the thumbnail image somehow starts at the top and get down when the player height increases.
is there any way to change it to start at the bottom and work it way up when players' height increases?
here is the script for the leaderstats that records players height
local function OnPlayerJoin(player) repeat wait() until player.Character local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local Height = Instance.new("IntValue") Height.Name = "Height" Height.Parent = leaderstats while wait() do Height.Value = (player.Character.HumanoidRootPart.Position.Y - 8) end end game.Players.PlayerAdded:Connect(OnPlayerJoin)
here is the script for the thumbnail that will go up and down based on the leaderstat height
local MaxHeight = 200 local Player = game.Players.LocalPlayer local LeaderStats = Player:WaitForChild("leaderstats") local Height = LeaderStats:WaitForChild("Height") local Icon = Instance.new("ImageLabel") local START_POSITION = UDim2.new(0, 0, 0, 0) Icon.BackgroundTransparency = 1 Icon.Size = UDim2.new(0.05,0,0.05,0) Icon.Position = START_POSITION local RatioConstraint = Instance.new("UIAspectRatioConstraint",Icon) local UserId = Player.UserId local ThumbnailType = Enum.ThumbnailType.HeadShot local ThumbnailSize = Enum.ThumbnailSize.Size420x420 local Thumbnail, isReady = game.Players:GetUserThumbnailAsync(UserId, ThumbnailType, ThumbnailSize) Icon.Image = Thumbnail Icon.Parent = script.Parent local function PlaceIcon() Icon:TweenPosition(UDim2.new(0.95,0,(Height.Value/MaxHeight),0),Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.2,true) end game:GetService("RunService"):BindToRenderStep("BindPosition", 1, PlaceIcon)
I am wondering what's wrong with the code above that makes the image thumbnail start at the top instead of the bottom.
The problem you are facing is that higher the value for Y, lower the image is. You can decrease its value from 1, so the height of the icon becomes directly proportional to the height of the character :) Edit this line:
Icon:TweenPosition(UDim2.new(0.95,0,1 -(Height.Value/MaxHeight),0),Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.2,true)
It's because the starting Y value was 0 so it was placed at the top So if you noticed, I made the starting Y value 0.95
local MaxHeight = 200 local Player = game.Players.LocalPlayer local LeaderStats = Player:WaitForChild("leaderstats") local Height = LeaderStats:WaitForChild("Height") local Icon = Instance.new("ImageLabel") local START_POSITION = UDim2.new(0, 0, 0.95, 0) Icon.BackgroundTransparency = 1 Icon.Size = UDim2.new(0.05,0,0.05,0) Icon.Position = START_POSITION local RatioConstraint = Instance.new("UIAspectRatioConstraint",Icon) local UserId = Player.UserId local ThumbnailType = Enum.ThumbnailType.HeadShot local ThumbnailSize = Enum.ThumbnailSize.Size420x420 local Thumbnail, isReady = game.Players:GetUserThumbnailAsync(UserId, ThumbnailType, ThumbnailSize) Icon.Image = Thumbnail Icon.Parent = script.Parent local function PlaceIcon() Icon:TweenPosition(UDim2.new(0.95,0,(Height.Value/MaxHeight),0),Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.2,true) end game:GetService("RunService"):BindToRenderStep("BindPosition", 1, PlaceIcon)