Tween happening instantly

Hello! I’m working on a MGSV weapon system and I’m working on the recoil.
Currently I have it so that the crosshair will upsize when shooting. What I want to do is downsize the crosshair, and this is all happening but it’s happening instantly, which I don’t want.
end)

Here’s the problematic part of the script.

LocalScript
mouse.Button1Down:Connect(function()
	if script.Parent.Parent:FindFirstChild("Humanoid") then
		repeat
			shooting = true
			local cam = workspace.CurrentCamera
			cam.CFrame=cam.CFrame*CFrame.Angles(math.random(-5,100)/360,math.random(-5,50)/360,0)
			local reticle = plr.PlayerGui:FindFirstChild("Reticle")
			reticle.ImageLabel.Size = reticle.ImageLabel.Size + UDim2.new(0,10,0,5)
			local TS = game:GetService("TweenService")
			local TI = TweenInfo.new(1)
			local part = reticle.ImageLabel
			local goal = {}
			part.Size = UDim2.new(0,94,0,56)
			local tween = TS:Create(part,TI,goal)
			tween:Play()
			wait(.1)
		until shooting == false
	end

And here’s a video of what’s happening.
https://gyazo.com/642a8cf88ad2248c8d96cb3f974a857b

Here’s the full script if needed.

Full Local Script
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local animator = char:FindFirstChild("Humanoid"):FindFirstChild("Animator")
local anim = script.Parent.Settings.AimAnim
local load = animator:LoadAnimation(anim)
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local crosshair
local aimcam
local shooting = false

script.Parent.AncestryChanged:Connect(function()
	if script.Parent.Parent:FindFirstChild("Humanoid") then
		script.Parent.EquipScriptRE:FireServer()
	else
		shooting = false
	end
end)

mouse.Button2Down:Connect(function()
	if script.Parent.Parent:FindFirstChild("Humanoid") then
		script.Parent.AimScriptRE:FireServer()
		load:Play()
		aimcam = script.Parent.AimCam:Clone()
		aimcam.Parent = plr.Character
		aimcam.Enabled = true
		crosshair = script.Parent.Settings.Reticle:Clone()
		crosshair.Parent = plr.PlayerGui
		crosshair.Enabled = true
	end
end)
mouse.Button2Up:Connect(function()
	if script.Parent.Parent:FindFirstChild("Humanoid") then
		script.Parent.AimScriptRE2:FireServer()
		load:Stop()
		aimcam:Destroy()
		crosshair:Destroy()
	end
end)

mouse.Button1Down:Connect(function()
	if script.Parent.Parent:FindFirstChild("Humanoid") then
		repeat
			shooting = true
			local cam = workspace.CurrentCamera
			cam.CFrame=cam.CFrame*CFrame.Angles(math.random(-5,100)/360,math.random(-5,50)/360,0)
			local reticle = plr.PlayerGui:FindFirstChild("Reticle")
			reticle.ImageLabel.Size = reticle.ImageLabel.Size + UDim2.new(0,10,0,5)
			local TS = game:GetService("TweenService")
			local TI = TweenInfo.new(1)
			local part = reticle.ImageLabel
			local goal = {}
			part.Size = UDim2.new(0,94,0,56)
			local tween = TS:Create(part,TI,goal)
			tween:Play()
			wait(.1)
		until shooting == false
	end
end)

mouse.Button1Up:Connect(function()
	if script.Parent.Parent:FindFirstChild("Humanoid") then
		shooting = false
	end
end)

I know it’s it is upsizing and downsizing because moving the tween to after the repeat will show the UI upsizing then being instantly fixed to it’s normal size after the repeat is finished.

That’s because the part size isn’t in the goal table.
image
You have to insert it inside the table to make it work otherwise it won’t work.

Here’s how it’s suppose to look like

local goal = {Size = UDim2.new(0,94,0,56)}

Let me know if theres any problems.

1 Like

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