Hello, I am trying to make an interaction script. Having some small troubles, probably easy to fix so I have come here for help.
I’ve added a specific section to my code, and for some reason it’s just not working. Essentially, once the progress fill circle reaches the same size of the outer circle, a click noise should play and the gui should go away, as well as I also need to reset the size of the Fill to it’s original size so that if the player walks up to interact again it will fill.
This is the code I added.
if Fill.Size.X.Scale == 1 then print("Fill.Size.X.Scale is == to 1") Fill:TweenSizeAndPosition (UDim2.new(0, 0, 0, 0), UDim2.new(.5, 0, .5, 0), "Out", "Linear", 0, true) ClickNoise:Play() end
This is my entire script for it.
local mouse = game.Players.LocalPlayer:GetMouse() local RS = game:GetService('RunService') local Player = game.Players.LocalPlayer local PlayerGui = Player.PlayerGui local interaction = PlayerGui:FindFirstChild('Main').Interact local UserInputService = game:GetService('UserInputService') local Fill = PlayerGui:FindFirstChild('Main').Interact.Fill local ClickNoise = PlayerGui:FindFirstChild('Main').Interact.ClickNoise local targetc --local hastarget local isUp = false RS.RenderStepped:Connect(function() local target = mouse.Target if target then if target.Name == "Right Arm" or target.Name == "Left Arm" or target.Name =="Left Leg" or target.Name == "Right Leg" then targetc = game.Players:GetPlayerFromCharacter(target.Parent) --hastarget = true interaction.Visible = true interaction.Position = UDim2.new(0, mouse.X + 15, 0, mouse.Y +5) mouse.Button1Down:Connect(function() --print("Click event started") if not isUp then --print(Fill) Fill.Visible = true Fill:TweenSize(UDim2.new(0, 96, 0, 95), "Out", "Linear", 1, false) --print("Held event registered") end mouse.Button1Up:Connect(function() isUp = true --print("Click or held event ended") end) end) if Fill.Size.X.Scale == 1 then print("Fill.Size.X.Scale is == to 1") Fill:TweenSizeAndPosition (UDim2.new(0, 0, 0, 0), UDim2.new(.5, 0, .5, 0), "Out", "Linear", 0, true) ClickNoise:Play() end else --print("Mouse is now on object other than Left/Right Arm or Left/Right Legs") interaction.Visible = false --hastarget = false end if targetc then end else --print("nothing is being hovered on") interaction.Visible = false end --warn(hastarget) end)