TweenService doesn't Working?

well I am trying to Change the location of this ViewportFrame with Tween after player click Hatch egg Button

The functions looks like working it Prints before and after Tween but nothing happens to ViewportFrame

local TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local TweenService = game:GetService("TweenService")
local EggHatchFrame = game.StarterGui.ScreenGui.EggHatchFrame

PetHatched.OnClientEvent:Connect(function(pet: table)
	print("We received a"..pet.Name)
	local megistus =  TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.fromScale(0.391, 0,0.5, 0);}):Play()
	print("Welp")
end)

any ideas would be helpfull
(it print’s “Welp” too.)

This should be changed to UDim2.new since you are giving both Offset and Scale for the position property.

still doesn’t work >30Char<>30Char<

You are also applying changes to the StarterGui instead of the PlayerGui, any changes would not be shown since everything from StarterGui is cloned to the PlayerGui.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer

local PlayerGui = Player:WaitForChild("PlayerGui") or Player.PlayerGui
local EggHatchFrame = PlayerGui.ScreenGui.EggHatchFrame

Can you please share other part of the script. Because everything seems right.

local Workspace= game:GetService("Workspace")
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local Players= game:GetService("Players")
local BuyEgg= ReplicatedStorage.Remotes.Shop.BuyEgg
local PetHatched= ReplicatedStorage.Remotes.Shop.PetHatched
local Player = Players.LocalPlayer

local TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local TweenService = game:GetService("TweenService")
local EggHatchFrame = game.StarterGui.ScreenGui.EggHatchFrame

local EggsFolder = Workspace.Eggs
local PetModels = ReplicatedStorage.Pets
local part = Workspace.Part
local EggConfig = require(ReplicatedStorage.Config.Eggs)

local template= script.Parent.Template

local function GetRarityColor(rarity: string)
print(rarity)	
	local color
	if rarity == "Common" then
		color= Color3.fromRGB(136, 136, 136)
	elseif rarity == "Uncommon" then
		color= Color3.fromRGB(83, 255, 97)
	elseif rarity == "Rare" then
		color= Color3.fromRGB(55, 98, 199)
	elseif rarity == "Legendary" then
		color= Color3.fromRGB(225, 244, 50)
	end
	return color
end
local function GetChanceColor(chance: number)
	print(chance)
	if chance <101 then
		chance  = Color3.fromRGB(255,255,255)
	end
	return chance
end
local function GenerateViewportFrame(viewportFrame:ViewportFrame, petModel:Model)
	petModel:PivotTo(CFrame.new()*CFrame.Angles(0,math.rad(90),0))
	petModel.Parent=viewportFrame
	local camera = Instance.new("Camera",viewportFrame)
	viewportFrame.CurrentCamera= camera
	camera.CFrame = CFrame.new(Vector3.new(0,0,3),petModel.PrimaryPart.Position)
	
end
local function GeneratePet(container: Frame, petConfig: table)
	print(petConfig)
	local clone = container.template:Clone()
	clone.Parent = container
	clone.Name = petConfig.Name
	clone.Visible = true
	clone.ViewportFrame.PetName.Text =petConfig.Chance.."%"
	clone.ViewportFrame.PetName.TextColor3 = GetChanceColor(petConfig.Chance)
	clone.ViewportFrame.Rarity.Text = petConfig.Rarity
	clone.ViewportFrame.Rarity.TextColor3 = GetRarityColor(petConfig.Rarity)
		
	local petClone = PetModels[petConfig.Name]:Clone()
	GenerateViewportFrame(clone.ViewportFrame,petClone)
end

	

local function GenerateBillBoardGui(eggModel:Instance,eggConfig: table)
	print(eggConfig)
	local Attachment = eggModel.Egg.Attachment
	local Clone = template:Clone()
	Clone.Parent = script.Parent
	Clone.Adornee = Attachment
	Clone.Name= eggModel.Name
	for _,pet in ipairs(eggConfig.Pets) do
		GeneratePet(Clone.Frame.Container, pet)	
	end
	Clone.Frame.Buttons.Auto.MouseButton1Click:Connect(function()
		--if not Players.gamepass.AutoHatch.Value then
			-- Prompt them to the Purchase the Gamepass
		--else
			BuyEgg:FireServer(eggModel.Name,"Auto")
	--	end
	end)
	Clone.Frame.Buttons.X1.MouseButton1Click:Connect(function()
		BuyEgg:FireServer(eggModel.Name)
	end)
	Clone.Frame.Buttons.X3.MouseButton1Click:Connect(function()
--		if not Players.gamepass.X3GamePass.Value then
			-- Prompt them to the Purchase the Gamepass
--		else
			BuyEgg:FireServer(eggModel.Name,"X3")
--		end
	end)
end

GenerateBillBoardGui(EggsFolder.Basic_Egg, EggConfig.Basic_Egg)

PetHatched.OnClientEvent:Connect(function(pet: table)
	print("We received a"..pet.Name)
	local megistus =  TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.new(0.391, 0,0.5, 0);}):Play()
	print("Welp")
end)

I don’t think this is the problem because I checked after it but
I tried yours

there isn’t any script worth meintoin but here you go



uhh that’s because you’re using it as a variable, and you’re using UDim2.fromScale even though it looks like UDim2.new

Did you call LocalScript from ServerSideScript? If you did’nt it wont work.

For example:

--LocalScript
PetHatched.OnClientEvent:Connect(function(pet: table)
	print("We received a"..pet.Name)
	local megistus =  TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.new(0.391, 0,0.5, 0);}):Play()
	print("Welp")
end)
--ServerSideScript

PetHatched:FireClient(Player)

Change

local TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local TweenService = game:GetService("TweenService")
local EggHatchFrame = game.StarterGui.ScreenGui.EggHatchFrame

PetHatched.OnClientEvent:Connect(function(pet: table)
	print("We received a"..pet.Name)
	local megistus =  TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.fromScale(0.391, 0,0.5, 0);}):Play()
	print("Welp")
end)

to

local TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local TweenService = game:GetService("TweenService")
local EggHatchFrame = game.StarterGui.ScreenGui.EggHatchFrame

PetHatched.OnClientEvent:Connect(function(pet: table)
	print("We received a"..pet.Name)
	local megistus =  TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.fromScale(0.391, 0,0.5, 0);})
    megistus:Play()
	print("Welp")
end)

You’re trying to play the tween in the same variable it’s set in.

This didn’t worked too I tried with a normal part you don’t need “megistus:Play()” part

I didn’t call but which script you mean by ServerSideScript?

Well. we already tried that. still not working

did you read “uhh that’s because you’re using it as a variable”?

yes and I changed it to this but still not working

PetHatched.OnClientEvent:Connect(function(pet: table)

print("We received a"..pet.Name)

TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.new(0.391, 0,0.5, 0);}):Play()

print("Welp")

end)

or

PetHatched.OnClientEvent:Connect(function(pet: table)

print("We received a"..pet.Name)

local Megistus = TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.new(0.391, 0,0.5, 0);})

Megistus:Play()

print("Welp")

end)

Both not working

You should only use UDim2.fromScale() with 2 arguments like UDim2.fromScale(X,Y)
Here is the updated code:

Nothing changed >30CharThinggz<

I edited the previous message, take a look


This is the script that i mention. If you still haven’t completed the hatching script, do the GUI later. When the player clicks on the proximity prompt or whatever, call this remote event with serversidescript(with the script I linked). Also you dont need to use remote event, If you made the player clicked script in local script. Put the tween in the player clicked script.

Edit: Also lemme check your local script