Hi! I’m trying to tween Frame under GunUI from a tool, but I’m getting the error GunUI is not a valid member of PlayerGui
, I’ve tried changing it to StarterGui but then the Tween doesn’t work. This is issuing from a LocalScript.
Here’s my script:
local tool = script.Parent
local plr = game:GetService("Players").LocalPlayer
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local part = PlayerGui.GunUI.Frame
part.Position = UDim2.new(-0.2, 0, 0.75, 0)
local goal1 = {}
goal1.Position = UDim2.new(0, 0, 0.75, 0)
local goal2 = {}
goal2.Position = UDim2.new(-0.2, 0, 0.75, 0)
local tweenInfo1 = TweenInfo.new(1)
local tween1 = TweenService:Create(part, tweenInfo1, goal1)
local tweenInfo2 = TweenInfo.new(1)
local tween2 = TweenService:Create(part, tweenInfo2, goal2)
tool.Equipped:Connect(function()
tween2:Cancel()
tween1:Play()
end)
tool.Unequipped:Connect(function()
tween2:Play()
tween1:Cancel()
end)
The reason it cancels the other tween is because if players spam the tool, I don’t want the tweens to break.
Any help is appreciated!