Ello my fellow air breathing humans if you can help ya boy out in any way let me know so in short definition this is what I want - What I want
I want the door to open by tween but nah seriously I just want it when a player touches the door for it to open up What I did
so I put this script in starterPlayerScripts because I want this to be local in the client I donāt want it to be in the server and I messed up the script since Iām new to scripting and would like some feedback on how I can fix it and learn!
for i,v in pairs(workspace.Door1) do
v.Touched:connect(function(h)
if h.Parent:FindFirstChild('LowerTorso') and debounce == false then
print("Touched")
debounce = true
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
1,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
0,
false,
0
)
local Goals = {
Position = Vector3.new(-1273.287, 50.945, 21110.467),
Orientation = Vector3.new(0, -140, 0)
}
local MakeTheDoorOpen = TweenService:Create(v, Info, Goals)
MakeTheDoorOpen:Play()
debounce = false
end
Is this the entire script? I only see 2 ends but you should have 3. One for the loop, one for the touched function, and one for the if statement. Also, is the print working?
If I add another end I get an error like you know the red line I get that. And no the print doesnāt seem to work I guess itās not identifying the door even though there is only one ādoor1ā in the game
Iām not sure if this is entire correct but you know that i, v in pairs only runs once so it might run before your even touching it. shouldnāt you put it in a loop or even a .touched function?
local player = game.Players.LocalPlayer
local door1 = workspace.Door1
local open = false
door1.Touched:Connect(function(hit)
if hit.Parent.Name == player.Name and open == false then
open = true
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local Goals = {
Position = Vector3.new(-1273.287, 50.945, 21110.467),
Orientation = Vector3.new(0, -140, 0)
}
local MakeTheDoorOpen = TweenService:Create(door1, Info, Goals)
MakeTheDoorOpen:Play()
MakeTheDoorOpen.Completed:Wait()
end
end)
You canāt use for i, v in pairs on a mesh. A for loop is only used to loop through a table of items. You donāt even need the for loop there, just remove it, define the door at the top local door = workspace.Door1 then instead of the for loop put door.Touched:Connect(function(hit)