Gui Tween Not Working?

I’m trying to make an image that moves up to the center of the screen after you die but for some reason it just appears there and doesnt move at all, I’m kinda new to scripting so i probably just made a mistake.

–Here’s The Script

local player = game:GetService(“Players”).PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)
local GoalPosition = “0.265, 0,0.096, 0”
local OriginPosition = “0, 786,0, 631”

local TweenService = game:GetService(“TweenService”)
local TweenImage = game:GetService(“StarterGui”).TweenImage.ImageLabel

humanoid.Died:Connect(function()
print(“cool”)
local goal1 = {}
goal1.Position = UDim2.new(tonumber(GoalPosition))

local TweenInfo1 = TweenInfo.new(0.45, Enum.EasingStyle.Sine)

local Tween1 = TweenService:Create(TweenImage, TweenInfo1, goal1)

end)

3 Likes

You can’t change it from the StarterGui, try using PlayerGui

1 Like

I have ran into a similar problem, you have to get the gui from the player.

game:GetService(“Players”).LocalPlayer.PlayerGui

Instead of

game:GetService(“StarterGui”)

I have it in ServerScriptService and im using a server script not a local script do you have any other suggestions?

You can use the PlayerAdded Event to achieve changes

example:

game.Players.PlayerAdded:Connect(plr)
        local plrGui = plr.PlayerGui
end)

And use the CharacterAdded Event to recieve changes with their Humanoid

example:

plr.CharacterAdded:Connect(function(char)

end)

sorry to ask, but where should i implement this in my script?

Here are some things to consider:

local player = game:GetService(“Players”).PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()

You can remove those two lines and add in PlayerAdded and CharacterAdded event:

game:GetService("Players").PlayerAdded:Connect(function(plr)
       plr.CharacterAdded:Connect(function()


end)

You’ll need the plr’s PlayerGui, so you can do this to get it:

local PlayerGui = plr.PlayerGui

For

I don’t understand why you would do this, you can use UDim2.new() and place those numbers in there.

Thank you
If you have any questions, please ask.

im not getting any errors but in the output it shows this: Infinite yield possible on ‘Players.WindyTundra:WaitForChild(“Humanoid”)’

local plr = game.Players.WindyTundra
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

thanks for the help with this!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.