Looking for general scripting help - with an entrance gate

Hi all, first time posting in this Topic.

I’m very, very new to scripting, so hopefully this is a question I can post in this space.

I’m looking for help, or a push in the right direction, to script this gate to a parking garage. The goal right now is to just get it to open, stay open for a couple of seconds, then automatically close without the need to use any prompts again. In the future, I’d like to implement a credit system, to allow for users to use X credit(s) to enter and exit parking garage.

I’ve tried to look for tutorials, mainly looking for either gates or doors and reconfiguring them to match my needs, to no avail, and I’ve hit a brick wall.

I’m not looking for someone to write a script for me, just a push in the right direction, either via other tutorials, or just advice. Anything is appreciated, especially because I have virtually 0 scripting knowledge, but I’d like to give it a shot.

Thank you.

1 Like

-if this is not an appropriate question for this Topic, I’ll delete and look elsewhere for answers. Thank you again.

1 Like

The only things you need is prompt triggered, the number of seconds you want it to remain open, and the use of TweenService (or how you plan on opening and closing). Just to give you a base.

local TIME_BEFORE_CLOSE = 5
Prompt.PromptTriggered:Connect(function() -- Will run every time the user triggers the prompt
	TweenService:Create(gate, TweenInfo.new(--[[whatever settings you want for the tween]]), {Position = OpenedPosition} --[[this is the position to end]] ):Play()
	task.wait(TIME_BEFORE_CLOSE)
	TweenService:Create(gate, TweenInfo.new(--[[whatever settings you want for the tween]]), {Position = ClosedPosition} --[[this is the position to end]] ):Play()
end)
1 Like

You can run the code to raise the gate when the proximity prompt’s event Prompt.Triggered() is fired. This event is fired when you activate the prompt by finishing holding it. Here’s an example

local function OpenGate()
   —[[Write code here to open the gate, you will learn how to soon enough]]—
end
local ProximityPrompt = game.Workspace.Gate.ProximityPrompt
ProximityPrompt.Triggered:Connect(OpenGate)

With this template, you can do stuff when the prompt is triggered which leads to dynamic gameplay for your games