i am trying to make my custom proximity prompt clickable and i am having trouble making it work.
local proximityprompts = {}
local PromptGui = script.Parent:WaitForChild("BillBoardGui")
local Tweenservice = game:GetService("TweenService")
local ti = TweenInfo.new(1/4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local t2 = TweenInfo.new(1/4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
function proximityprompts:Create(Prompt, inputtype)
local PromptGui = PromptGui:Clone()
PromptGui.Parent = script
PromptGui.Adornee = Prompt.Parent
PromptGui.Enabled = true
PromptGui.Frame.ActionText.Text = Prompt.ActionText
PromptGui.Frame.key.Text = Prompt.KeyboardKeyCode.Name
PromptGui.Frame.ObjectText.Text = Prompt.ObjectText
PromptGui.Frame.Size = UDim2.fromScale(1, 0)
local tweenout = Tweenservice:Create(PromptGui.Frame.Background.FillIn, t2, {Size = UDim2.new(0, 200,0, 0)})
local tweenin = Tweenservice:Create(PromptGui.Frame.Background.FillIn, ti, {Size = UDim2.new(2, 0,10, 0)})
if inputtype == Enum.ProximityPromptInputType.Touch or Prompt.ClickablePrompt then
local button = Instance.new("TextButton")
local buttonDown = false
button.BackgroundTransparency = 1
button.TextTransparency = 1
button.Size = UDim2.fromScale(1,1)
button.Parent = PromptGui
button.InputBegan:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
input.UserInputState ~= Enum.UserInputState.Change then
Prompt:InputHoldBegin()
buttonDown = true
end
end)
button.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
if buttonDown then
buttonDown = false
Prompt:InputHoldEnd()
end
end
end)
end
PromptGui.Active = true
return {
Appear = tweenin,
Dissappear = tweenout,
Destroy = function()
tweenout:Play()
tweenout.Completed:Wait()
PromptGui:Destroy()
end}
end
local players = game:GetService("Players")
local localplayer = players.LocalPlayer
game:GetService("ProximityPromptService").PromptShown:Connect(function(prompt, inputtype)
if prompt.Style ~= Enum.ProximityPromptStyle.Custom then
return
end
local functions = proximityprompts:Create(prompt)
local bind = prompt.Triggered:Connect(function(f)
if f == localplayer then
functions.Appear:Play()
end
end)
local bind2 = prompt.TriggerEnded:Connect(function(f)
if f == localplayer then
functions.Dissappear:Play()
end
end)
prompt.PromptHidden:Wait()
functions:Destroy()
end)
local proximityprompts = {}
local PromptGui = script.Parent:WaitForChild("BillBoardGui")
local Tweenservice = game:GetService("TweenService")
local players = game:GetService("Players")
local localplayer = players.LocalPlayer
local playerGui = localplayer:WaitForChild("PlayerGui")
local ti = TweenInfo.new(1/4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local t2 = TweenInfo.new(1/4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
function proximityprompts:Create(Prompt, inputtype)
local PromptGui = PromptGui:Clone()
PromptGui.Parent = playerGui
PromptGui.Adornee = Prompt.Parent
PromptGui.Enabled = true
PromptGui.Frame.ActionText.Text = Prompt.ActionText
PromptGui.Frame.key.Text = Prompt.KeyboardKeyCode.Name
PromptGui.Frame.ObjectText.Text = Prompt.ObjectText
PromptGui.Frame.Size = UDim2.fromScale(1, 0)
local tweenout = Tweenservice:Create(PromptGui.Frame.Background.FillIn, t2, {Size = UDim2.new(0, 200,0, 0)})
local tweenin = Tweenservice:Create(PromptGui.Frame.Background.FillIn, ti, {Size = UDim2.new(2, 0,10, 0)})
if inputtype == Enum.ProximityPromptInputType.Touch or Prompt.ClickablePrompt then
local button = Instance.new("TextButton")
local buttonDown = false
button.BackgroundTransparency = 1
button.TextTransparency = 1
button.Size = UDim2.fromScale(1,1)
button.Parent = PromptGui
button.InputBegan:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
input.UserInputState ~= Enum.UserInputState.Change then
Prompt:InputHoldBegin()
buttonDown = true
end
end)
button.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
if buttonDown then
buttonDown = false
Prompt:InputHoldEnd()
end
end
end)
end
PromptGui.Active = true
return {
Appear = tweenin,
Dissappear = tweenout,
Destroy = function()
tweenout:Play()
tweenout.Completed:Wait()
PromptGui:Destroy()
end}
end
game:GetService("ProximityPromptService").PromptShown:Connect(function(prompt, inputtype)
if prompt.Style ~= Enum.ProximityPromptStyle.Custom then
return
end
local functions = proximityprompts:Create(prompt)
local bind = prompt.Triggered:Connect(function(f)
if f == localplayer then
functions.Appear:Play()
end
end)
local bind2 = prompt.TriggerEnded:Connect(function(f)
if f == localplayer then
functions.Dissappear:Play()
end
end)
prompt.PromptHidden:Wait()
functions:Destroy()
end)
local proximityprompts = {}
local PromptGui = script.Parent:WaitForChild("BillBoardGui")
local Tweenservice = game:GetService("TweenService")
local players = game:GetService("Players")
local localplayer = players.LocalPlayer
local playerGui = localplayer:WaitForChild("PlayerGui")
local ti = TweenInfo.new(1/4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local t2 = TweenInfo.new(1/4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
function proximityprompts:Create(Prompt, inputtype)
local PromptGuiC = PromptGui:Clone()
PromptGuiC.Parent = playerGui
PromptGuiC.Adornee = Prompt.Parent
PromptGuiC.Enabled = true
PromptGuiC.Frame.ActionText.Text = Prompt.ActionText
PromptGuiC.Frame.key.Text = Prompt.KeyboardKeyCode.Name
PromptGuiC.Frame.ObjectText.Text = Prompt.ObjectText
PromptGuiC.Frame.Size = UDim2.fromScale(1, 0)
local tweenout = Tweenservice:Create(PromptGui.Frame.Background.FillIn, t2, {Size = UDim2.new(0, 200,0, 0)})
local tweenin = Tweenservice:Create(PromptGui.Frame.Background.FillIn, ti, {Size = UDim2.new(2, 0,10, 0)})
if inputtype == Enum.ProximityPromptInputType.Touch or Prompt.ClickablePrompt then
local button = Instance.new("TextButton")
local buttonDown = false
button.BackgroundTransparency = 1
button.TextTransparency = 1
button.Size = UDim2.fromScale(1,1)
button.Parent = PromptGui
button.InputBegan:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
input.UserInputState ~= Enum.UserInputState.Change then
Prompt:InputHoldBegin()
buttonDown = true
end
end)
button.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
if buttonDown then
buttonDown = false
Prompt:InputHoldEnd()
end
end
end)
end
PromptGuiC.Active = true
return {
Appear = tweenin,
Dissappear = tweenout,
Destroy = function()
tweenout:Play()
tweenout.Completed:Wait()
PromptGui:Destroy()
end}
end
game:GetService("ProximityPromptService").PromptShown:Connect(function(prompt, inputtype)
if prompt.Style ~= Enum.ProximityPromptStyle.Custom then
return
end
local functions = proximityprompts:Create(prompt)
local bind = prompt.Triggered:Connect(function(f)
if f == localplayer then
functions.Appear:Play()
end
end)
local bind2 = prompt.TriggerEnded:Connect(function(f)
if f == localplayer then
functions.Dissappear:Play()
end
end)
prompt.PromptHidden:Wait()
functions:Destroy()
end)