You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I love the style of custom prompts in games like: Jailbreak, Wild West, that were used before ProximityPrompts were a thing. Especially like what Egg Hunt 2018 used.
-
What is the issue? Include screenshots / videos if possible!
I attempted to give it a shot myself, however im very inexperienced so its no suprise I couldnt get it working. I used a Billboard Frame, Module Scripts for the tween, click detection and the actual main module i call from a localscript. The issue is that If i make multiple instances (LocalScript and the gui) they function as one and can be activated only by the last prompt.
On top of that the click detection doesnt even work. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
There doesnt seem to be much on this topic here or atleast couldnt find it. The only solution that would I can think of is to ditch the modules and put it all in one script.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!¨
Main Module
local ProximityBubbleModule = {}
local module = require(game.ReplicatedStorage.ProxBubble.TweenModule)
function ProximityBubbleModule.Initialize(player, proxBubble)
ProximityBubbleModule.Activated = false
local tweenlength = 0.75
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local CD = require(game.ReplicatedStorage.ClickDetect)
local Image = proxBubble.ImageButton
local bubbleNear = "rbxassetid://115943053973095"
local bubbleFar = "rbxassetid://98198133428899"
ProximityBubbleModule.object = proxBubble.Adornee
local checkforpos = true
local distance = Image:FindFirstChild("FarDistance") and Image.FarDistance.Value or 0
local distanceMax = Image:FindFirstChild("MAXDistance") and Image.MAXDistance.Value or 0
module.Initialize(tweenlength, proxBubble)
while checkforpos do
if ProximityBubbleModule.object then
local playerPos = player.Character.HumanoidRootPart.Position
local objectPos = ProximityBubbleModule.object.Position
if (objectPos - playerPos).magnitude < distance then --STATE 1 - set to nearImage
proxBubble.Enabled = true
module.tweenscaleOut:Play()
Image.Image = bubbleNear
ProximityBubbleModule.isStage1 = true
if CD.justClicked then
ProximityBubbleModule.Activated = true
task.wait(0.01)
ProximityBubbleModule.Activated = false
end
elseif (objectPos - playerPos).magnitude <= distanceMax then --STATE 2 - set to farImage
module.tweenscaleIn:Play()
Image.Image = bubbleFar
proxBubble.Enabled = true
ProximityBubbleModule.isStage1 = false
else --STATE 3 - disable
proxBubble.Enabled = false
ProximityBubbleModule.isStage1 = false
end
end
task.wait(.01)
end
end
return ProximityBubbleModule
Click Detection
local module = {}
local userInputService = game:GetService("UserInputService")
module.justClicked = false
local amountclicked = 0
local lastClickTime = 0
userInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if gameProcessed then return end
local currentTime = tick()
if currentTime - lastClickTime >= .5 then
amountclicked = amountclicked + 1
lastClickTime = currentTime
module.justClicked = true
task.wait(0.01)
module.justClicked = false
end
end
end)
return module
Tween Module
local module = {}
function module.Initialize(tweenlength, proxBubble)
local tweenService = game:GetService("TweenService")
local tweeninfoIn = TweenInfo.new(
tweenlength,
Enum.EasingStyle.Back,
Enum.EasingDirection.Out,
0,
false,
tweenlength/10
)
local tweeninfoOut = TweenInfo.new(
tweenlength,
Enum.EasingStyle.Back,
Enum.EasingDirection.Out,
0,
false,
tweenlength/10
)
local goaltweenIn = {}
goaltweenIn.Size = UDim2.new(1.25, 0, 1.25, 0)
module.tweenscaleIn = tweenService:Create(proxBubble, tweeninfoIn, goaltweenIn)
local goaltweenOut = {}
goaltweenOut.Size = UDim2.new(2, 0, 2, 0)
module.tweenscaleOut = tweenService:Create(proxBubble, tweeninfoOut, goaltweenOut)
end
return module
Gui LocalScript
local ProximityBubbleModule = require(game.ReplicatedStorage.ProxBubble.ProximityBubbleModule)
local player = game.Players.LocalPlayer
local proxBubble = player.PlayerGui:WaitForChild("ProxBubble.Char1")
local Frame = player.PlayerGui:WaitForChild("ScreenGui").ViewportFrame
ProximityBubbleModule.Initialize(player, proxBubble)
while true do
if ProximityBubbleModule.Activated then
Frame.Visible = true
print("ACTIVATED")
else
Frame.Visible = false
print("notactivated")
end
task.wait(0.01)
end
My bad if i made any mistakes writing this, Im completely new here.
I know the code is pretty awful but as i said im inexperienced so bear with me :3