The tween instance results: null, and doesn't play

i need help with 3 tweens

  1. they don’t work
  1. in the output says:

  2. i tried some solutions and the same thing but something say NIL

  3. here the script:

RunService.Stepped:Connect(function()
	for _, Drop:Model in WorkspaceDrops:GetChildren() do
		for i, Player in Players:GetChildren() do
			local Character = Player.Character or Player.CharacterAdded:Wait()
			if Character and Drop and Drop.Parent ~= nil then
				if (Character.PrimaryPart.Position - Drop.PrimaryPart.Position).Magnitude < 10 and Drop.CanCollect.Value == true then
					if Character:WaitForChild("Humanoid").Health ~= 0 then
					local ClickDetector:ClickDetector = Drop:WaitForChild("ClickDetector")
						ClickDetector.MouseClick:Connect(function(player)
							if not Debounces[Drop] then
								Debounces[Drop] = true
					
								ReplicatedStorage.Remotes.CollectDrop:Fire(Player,Drop.Name, false)
						
								task.wait(3)
						
								Debounces[Drop] = nil
							end
							
							ClickDetector:Destroy()
							
							local CFrameTween = TweenService:Create(Drop.PrimaryPart,TweenInfo.new(1),{CFrame = CFrame.Angles(math.random(0,360), math.random(0,360), math.random(0,360))})
							local SizeTween = TweenService:Create(Drop.PrimaryPart, TweenInfo.new(1), {Size = Vector3.new(0.001,0.001,0.001)})
							local TransparencyTween = TweenService:Create(Drop.PrimaryPart, TweenInfo.new(1), {Transparency = 1})
							
							CFrameTween:Play()
							SizeTween:Play()
							TransparencyTween:Play()
							
							wait(3)
							Drop:Remove()
							wait(5)
							Drop:Destroy()
						end)
					end
				end
			end
		end
	end
end)

please help idk what is happening please help :smiling_face_with_tear:

edit:
and last the remove then destroy is for after for no errors but doesn’t work

1 Like

Drop.PrimaryPart can be nil. I would check if Drop’s PrimaryPart is set correctly, whether it be in edit mode or through a script.

Side note, those tweens could be combined into one if you add the properties under one table. :slight_smile:

This is way too crammed together… making debugging very hard.
Try this … Also fully explain what you’re attempting to do here.

local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")

local debounce = {}

local function createTweens(Drop)
    local CFrameTween = ts:Create(Drop.PrimaryPart, TweenInfo.new(1), {CFrame = CFrame.Angles(math.random(0, 360), math.random(0, 360), math.random(0, 360)})
    local SizeTween = ts:Create(Drop.PrimaryPart, TweenInfo.new(1), {Size = Vector3.new(0.001, 0.001, 0.001)})
    local TransparencyTween = ts:Create(Drop.PrimaryPart, TweenInfo.new(1), {Transparency = 1})
    CFrameTween:Play()
    SizeTween:Play()
    TransparencyTween:Play()
end

local function handleClick(player, Drop)
    if not debounce[Drop] then
        debounce[Drop] = true
        game.ReplicatedStorage.Remotes.CollectDrop:Fire(player, Drop.Name, false)
        task.wait(3)
        debounce[Drop] = nil
    end
    Drop:Remove()
    wait(5)
    Drop:Destroy()
end

rs.Stepped:Connect(function()
    for _, Drop in pairs(workspace.Drops:GetChildren()) do
        for _, Player in pairs(game.Players:GetChildren()) do
            local Character = Player.Character
            if Character and Drop and Drop.Parent then
                local Humanoid = Character:FindFirstChild("Humanoid")
                if Humanoid and Humanoid.Health > 0 then
                    local ClickDetector = Drop:FindFirstChild("ClickDetector")
                    if ClickDetector then
                        ClickDetector.MouseClick:Connect(function()
                            handleClick(Player, Drop)
                        end)
                    end
                    createTweens(Drop)
                end
            end
        end
    end
end)

im going to test but i knew it was crammed because to start the project i used a little tutorial then fixed some bugs :expressionless:

1 Like

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