Hello, I’ve ran into a problem with using RunService
, When pressing E the UI stays there instead of playing the UI fade animation. It’s registering the bind press but not doing anything. Why is it doing this?
Clip:
-- Services --
local Players = game:GetService('Players')
local TweenService = game:GetService('TweenService')
local UserInputService = game:GetService('UserInputService')
local RunService = game:GetService('RunService')
-- Variables --
local Player = Players.LocalPlayer
local Character = Player.Character
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
local TweenInteract = TweenInfo.new(0.3,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
---
-- Functions --
local function GetDistance(Part1,Part2)
local Vec1 = Vector3.new(Part1.Position.X,0,Part1.Position.Z)
local Vec2 = Vector3.new(Part2.Position.X,0,Part2.Position.Z)
return (Vec1 - Vec2).Magnitude
end
---
-- UserInputService --
UserInputService.InputBegan:Connect(function(Input,Busy)
if Busy then return end
for OBJ,BillBoard in pairs(workspace:GetDescendants()) do
if BillBoard:IsA('BillboardGui') and BillBoard.Name == 'Prompt' then
if Input.KeyCode == Enum.KeyCode.E then
if GetDistance(HumanoidRootPart,BillBoard.Parent) <= 6 then
print('E')
local FrameGoal = {BackgroundTransparency = 1,Size = UDim2.new(0.6,0,0.6,0)}
local TextGoal = {TextTransparency = 1}
TweenService:Create(BillBoard.Frame,TweenInteract,FrameGoal):Play()
TweenService:Create(BillBoard.Frame.Text,TweenInteract,TextGoal):Play()
end
end
end
end
end)
---
-- RunService --
RunService.RenderStepped:Connect(function(Step)
-- For Statement --
for OBJ,BillBoard in pairs(workspace:GetDescendants()) do
if BillBoard:IsA('BillboardGui') and BillBoard.Name == 'Prompt' then
if GetDistance(HumanoidRootPart,BillBoard.Parent) <= 6 then
local FrameGoal = {BackgroundTransparency = 0,Size = UDim2.new(1,0,1,0)}
local TextGoal = {TextTransparency = 0}
TweenService:Create(BillBoard.Frame,TweenInteract,FrameGoal):Play()
TweenService:Create(BillBoard.Frame.Text,TweenInteract,TextGoal):Play()
else
local FrameGoal = {BackgroundTransparency = 1,Size = UDim2.new(0.6,0,0.6,0)}
local TextGoal = {TextTransparency = 1}
TweenService:Create(BillBoard.Frame,TweenInteract,FrameGoal):Play()
TweenService:Create(BillBoard.Frame.Text,TweenInteract,TextGoal):Play()
end
end
end
end)
---
-- Main --
---