How do i make a local sript start running through a proximity promt

im trying to make a custom dialogue box gui that the player makes it visible only for them by interacting with a proximity prompt

so when that proximity prompt gets activated i want the following script to start running (so it dosent run in the background while my gui isnt visible), but ofcourse only for the player who interacted with it. im not used to scripting so sorry if its a dumb question

wait (5)
script.Parent.Text = "test"
wait (3)
script.Parent.Text = "test 2"
wait (3)
script.Parent.Text = "test 3"

ProximityPrompts have something what’s called, a Triggered Event

This Event can trigger when a Player activates the Prompt with the specified key:
https://developer.roblox.com/en-us/api-reference/event/ProximityPrompt/Triggered

local TextLabel = script.Parent
local Prompt -- Define your ProximityPrompt Object here

Prompt.Triggered:Connect(function()
    wait(5)
    TextLabel.Text = "test"
    wait(3)
    TextLabel.Text = "test 2"
    wait(3)
    TextLabel.Text = "test 3"
end)
1 Like