Why is my tween not running?

So basically everything in my script is working fine except the wheat is teleporting instantly ontop of the dirt instead of slowly tweening up. Please help

local ServerStorage = game:GetService("ServerStorage")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local DirtFolder = game.Workspace.Dirt
local WheatClone = ServerStorage.Wheat
local Events = ReplicatedStorage.Events

local function grow(dirt)
	if dirt.HasWheat.Value == false then 
		local wheat = WheatClone:Clone()
		local GrowTime = dirt.GrowTime
		wheat.Parent = dirt
		dirt.HasWheat.Value = true
		TweenService:Create(wheat.PrimaryPart, TweenInfo.new(0), {CFrame = dirt.CFrame * CFrame.new(0, -1.3, 0) * CFrame.Angles(0, 0, 77)}):Play()
		TweenService:Create(wheat.PrimaryPart, TweenInfo.new(DirtFolder.TimeToGrow.Value), {CFrame = dirt.CFrame * CFrame.new(0, 2, 0) * CFrame.Angles(0, 0, 77)}):Play()
		while true do 
			task.wait(1)
			if GrowTime.Value < DirtFolder.TimeToGrow.Value then 
				GrowTime.Value += 1
			else
				GrowTime.Value = 0
				break
			end
		end
	end
end

Events.Grow.OnServerEvent:Connect(function(player, Dirt)
	if Dirt.HasWheat.Value == false then 
		grow(Dirt)
	end
end)

Alright so first tweenservice is my cheap hack to move the whole model under the block (Welded to one piece) And it works in tact. Then the second tween is what appears to not work. When I removed it the wheat was underneath in the right spot but when I added it back the wheat instantly teleported to fully grown.
image
As you can see shouldn’t be close to fully grown,

6 Likes

can you put this at the start of the grow function
print(DirtFolder.TimeToGrow.Value)

3 Likes


sorry I didn’t show this the value is at 60 and is not at 0,
image

2 Likes

try to type a specific number instead of timetogrow in the tween, this will help figure the problem

2 Likes

I did the number and it does the exact same thing meaning it doesnt tween up. Background information: it worked before perfectly then I added the event on when clicked which somehow broke it but I can’t figure out why. Local script for that but it should have nothing to do with it…

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local mouse = player:GetMouse()

local debounce = false

mouse.Button1Down:Connect(function()
	if debounce == false then 
		debounce = true
		local hit = mouse.Target
		if hit.Parent == game.Workspace.Dirt then 
			ReplicatedStorage.Events.Grow:FireServer(hit)
			task.wait(5)
			debounce = false
		end
	end
	
end)
1 Like

maybe try adding the remaining tweeninfo values ? mainly easingstyle
edit: now that i think about it if this was the issue it wouldnt work the first time so scrap that

2 Likes

Nope that didn’t change a thing. Also 0 errors in the output I’m extremely lost rn

my other guess is that maybe the tween is playing but another script is somehow already teleporting it to that position first, try to make the tween move the wheat to a completely random place and see if it tweens there

1 Like

Hmmm interesting. I made it tween to a random place and it did not move

I moved the dirt block and the wheat is now moving to it very slowly but it’s starting from where it was created not on the block

Try wheat:PivotTo(dirt.CFrame * CFrame.new(0, -1.3, 0) * CFrame.Angles(0, 0, 77))

instead of TweenService:Create(wheat.PrimaryPart, TweenInfo.new(0), {CFrame = dirt.CFrame * CFrame.new(0, -1.3, 0) * CFrame.Angles(0, 0, 77)}):Play()

3 Likes

perfect works great I should not of used my cheap fix and should of learnt how to move models properly!

1 Like

so basically, the first tween was somehow interfering with the second one ? interesting

1 Like

yeah I suppose so? I used a task.wait so i thought it’d work but good to know

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