-
**What do you want to achieve?
having problem with tween -
What is the issue?
works fine but when equip other tool it give an error
before:
after:
-
What solutions have you tried so far?
nothing
local player = game:GetService("Players").LocalPlayer
local GUI = player.PlayerGui:WaitForChild("GunGUI")
local tool = script.Parent
local main = GUI.Main
local HL = main.HL
local HR = main.HR
local VD = main.VD
local VU = main.VU
local center = main.Center
local sprint = false
--crosshair move
tool.Equipped:Connect(function()
player.Character.Humanoid.Running:Connect(function(speed)
if speed > 10 then
HL:TweenPosition(
UDim2.new(0, -97, 0, 0),
"Out",
"Linear",
0.18,
true
)
HR:TweenPosition(
UDim2.new(0, 90, 0, 0),
"Out",
"Linear",
0.18,
true
)
VD:TweenPosition(
UDim2.new(0, 0, 0, 90),
"Out",
"Linear",
0.18,
true
)
VU:TweenPosition(
UDim2.new(0, 0, 0, -97),
"Out",
"Linear",
0.18,
true
)
else
HL:TweenPosition(
UDim2.new(0, -57, 0, 0),
"Out",
"Linear",
0.18,
true
)
HR:TweenPosition(
UDim2.new(0, 50, 0, 0),
"Out",
"Linear",
0.18,
true
)
VD:TweenPosition(
UDim2.new(0, 0, 0, 50),
"Out",
"Linear",
0.18,
true
)
VU:TweenPosition(
UDim2.new(0, 0, 0, -57),
"Out",
"Linear",
0.18,
true
)
end
end)
end)
--sprint
player.Character.Humanoid.Running:Connect(function(speed)
if speed > 16 then
HL.Visible = false
HR.Visible = false
VD.Visible = false
VU.Visible = false
else
HL.Visible = true
HR.Visible = true
VD.Visible = true
VU.Visible = true
end
end)
tool.Equipped:Connect(function()
VU.Visible = false
VU.Transparency = 1
end)
--disable the viewmodel via unequip
tool.Unequipped:Connect(function()
VU.Transparency = 1
end)