Trigger Proximity Promp to move unioned part

Good morning.

  1. What i want to achieve? I want to make gate for my middle ages game, this gate will have proximity promp, who will show for specific team (Ottomans) and will open the gate with Cframe. After 60 seconds, gate will move back to oryginal position. ( In those 60 seconds button will be Disabled).

Here I will add some screenshots:
screenshot3

obraz

I was looking for it on Devforum but i didnt saw anything what can help me.

Thats my script:
local distanse = 13
local player = game:GetService(“Players”)

script.Parent.Parent.Anchored = true

script.Parent(function()
if player.team.name == “Ottomans” then
script.Parent.Enabled = true
else
script.Parent.Enabled = false
end
end)

script.Parent.Triggered:Connect(function()
if player.team.name == “Ottomans” then
script.Parent.Enabled = false
for i = 0, distanse do
script.Parent.Parent.CFrame = script.Parent.Parent.CFrame+Vector3(0,1,0)
wait()
end
wait(60)
for i = 0, distanse do
script.Parent.Parent.CFrame = script.Parent.Parent.CFrame+Vector3(0,-1,0)
wait()
end
script.Parent.Enabled = true
end
end)

Im new scripter and builder, i don’t have any developer team, i was trying to make RTS game, but without good dev team and scripting experience i can’t do anything. Thanks for Reading and help, have a nice day. Sorry for bad English.

A few things,

script.Parent(function()
	if player.team.name == “Ottomans” then
	script.Parent.Enabled = true
	else
	script.Parent.Enabled = false
	end
end)

Is going to error, as this is nothign somethign can do on Roblox

Also you’re going to error in the Triggered event as you can’t get team from the players service.

Use the parameter that you get from Triggered, which is the player who triggered the event, and use that to check their team if they’re an Ottomans or not

Thanks for help, have a nice day :slight_smile:

1 Like

Please tell me if you’re confused about something and i’ll try to help!

I think i understand everything, if I do not understand something, I will contact you, thanks for your help mate! :slight_smile:

1 Like

I wish you good luck with your work!

1 Like

Change the script to this and tell me if it works (I might be wrong myself):

local distance = 13

script.Parent.Triggered:Connect(function(player)
    if player.Team.Name == "Ottomans" then
        script.Parent.Enabled = false
        for i = 0, distance do
            script.Parent.Parent.Position += Vector3.new(0,1,0)
            wait()
        end
        wait(60)
        for i = 0,distance do
            script.Parent.Parent.Position -= Vector3.new(0,1,0)
            wait()
        end
        script.Parent.Enabled = true
    end
end)

Tell me if there are any errors.

2 Likes

Okay i will try, mabe it will work, thanks for help :slight_smile:

It works, thanks man, big thanks, you saved me, you are the best.

1 Like