Door opening By himself when i start game

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? To fix it. and when door not GONNA opening by himself when i start game

  2. What is the issue?
    I guees, To check IF player actually hitting the Card_1

Decetrion =  True

Dedectore.Touched:Connect(function(hit, plr)
	Decetrion = false
	if hit.Parent.Name == "Card_1" then
		if Decetrion == false then
			Decetrion = true
			print("open")
			DoorAnimation1:Play()
			DoorAnimation2:Play()
			Dedectore.Color = Color3.fromRGB(91, 255, 88)
			task.wait(2)
			Dedectore.Color = Color3.fromRGB(255, 0, 0)
			task.wait(0.5)
                        DoorAnimation3:Play()
			DoorAnimation4:Play()
			print("close")
			Decetrion = False
			     
			end
	end
end)
  1. What solutions have you tried so far? I checked youtobe, and i find out, if you make this by ProximityPrompt you don’t have problem like this
5 Likes

hit can be something else than player so put the decetrion inside the if statement

2 Likes

So i need somehow get player when he tuching the part? How i can make it?? or what you mean?

3 Likes

Does decetrion has any applications in your script? Or is there anything else that may cause the door to open?

3 Likes

Detection is just “False” no else, it’s like, Double check if Door in already openned

3 Likes

Does it print open when you launch the game without triggering the event with a card?

3 Likes

Yes it’s said open when i start the game

3 Likes

Can you take a screenshot of your explorer of how you setup the hiearchy.

3 Likes

I show you video, just game me 1 minute

3 Likes
Decetrion =  false

Dedectore.Touched:Connect(function(hit, plr)
	if hit.Parent.Name == "Card_1" and Decetrion == false then
		Decetrion = true
		print("open")
		DoorAnimation1:Play()
		DoorAnimation2:Play()
		Dedectore.Color = Color3.fromRGB(91, 255, 88)
		task.wait(2)
		Dedectore.Color = Color3.fromRGB(255, 0, 0)
	        task.wait(0.5)
                DoorAnimation3:Play()
		DoorAnimation4:Play()
		print("close")
		Decetrion = False
	end
end)
1 Like

Still no changes is same, so it’s not working

1 Like

Video (sorry for long respons, i just waited to loaded the video)

1 Like

dude send the whole script

also probably some other code is ruining this

1 Like
local AnimationService = game:GetService("TweenService")
local TweenInfor = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)


local RepublicStorage = game:GetService("ReplicatedStorage")

local Dedectore = script.Parent.Level_1
local Door1 = script.Parent.Door1
local Door2 = script.Parent.Door2
 
local Door1Position_Open = Door1.Position + Vector3.new(2,0,0) 
local Door2Position_Open = Door2.Position - Vector3.new(2,0,0) 
local DoorAnimation1 = AnimationService:Create(Door1, TweenInfor, {Position = Door1Position_Open})
local DoorAnimation2 = AnimationService:Create(Door2, TweenInfor, {Position = Door2Position_Open})

Decetrion = true

Dedectore.Touched:Connect(function(hit, plr) -- "plr is doing nohing here this is same as hit"
	Decetrion = false
	if hit.Parent.Name == "Card_1" or "Card_2" or "Card_3" or "Card_Chaos" or "Card_4" or "Card_5" or "Card_Omni" and  Decetrion == false  then
		 
			Decetrion = true
			print("open")
			DoorAnimation1:Play()
			DoorAnimation2:Play()
			Dedectore.Color = Color3.fromRGB(91, 255, 88)
			task.wait(2)
			Dedectore.Color = Color3.fromRGB(255, 0, 0)
			task.wait(0.5)
			print("close")
			Decetrion = true
			     
			
	end
end)
1 Like

try this and anchor the parts around your door

local AnimationService = game:GetService("TweenService")
local TweenInfor = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local RepublicStorage = game:GetService("ReplicatedStorage")

local Dedectore = script.Parent.Level_1
local Door1 = script.Parent.Door1
local Door2 = script.Parent.Door2

local Door1Position_Open = Door1.Position + Vector3.new(2,0,0) 
local Door2Position_Open = Door2.Position - Vector3.new(2,0,0) 
local DoorAnimation1 = AnimationService:Create(Door1, TweenInfor, {Position = Door1Position_Open})
local DoorAnimation2 = AnimationService:Create(Door2, TweenInfor, {Position = Door2Position_Open})

local Decetrion = false

Dedectore.Touched:Connect(function(hit)
	print(hit)
	if string.find(hit.Parent.Name, "Card") and not Decetrion then
		Decetrion = true
		print("open")
		DoorAnimation1:Play()
		DoorAnimation2:Play()
		Dedectore.Color = Color3.fromRGB(91, 255, 88)
		task.wait(2)
		Dedectore.Color = Color3.fromRGB(255, 0, 0)
		task.wait(0.5)
		print("close")
		Decetrion = false
	end
end)
2 Likes

Wow… HOW? you are the magic men. And before you go? “string.find” what he is doing?

1 Like

Oh daim, he is only working with Only 1 card, How i can put inside 2 and more names to the String?

1 Like

if it finds the pattern (the second value) in the first value (string) it returns true else it returns false

2 Likes

change
if string.find(hit.Parent.Name, "Card") and not Decetrion then
to
if (string.match(hit.Parent.Name, "Card") == "Card") and not Decetrion then

2 Likes

I just tried that, How you put here for example 3 cards “Card_1”, “Card_2”, and “Card_3” i just tried my self, and it’s i just can’t put more then 1 card Or i need Use Table for that?

1 Like