Cosnez
(Cosnez)
June 15, 2021, 8:05pm
#1
I have a door they required a key to open and it has to touch the keyhole to open and I want it where when the key touches the key hold a version of the same key goes where the keyhole is anyone know how to help me with the vector
Pedestal is where I want the key to go and key1 is the key to open the door and HandleDup is the thing I want on the pedestal
Could you possible post the code here. I cannot read the code in the image.
1 Like
Cosnez
(Cosnez)
June 15, 2021, 8:14pm
#3
Ye let me get on the pc hold up
Cosnez
(Cosnez)
June 15, 2021, 8:14pm
#4
"local doormodel = script.Parent
HandleDup = game.Workspace.HandleDup
local TweenService = game:GetService(“TweenService”)
local doorTweenInfo = TweenInfo.new(
4,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false,
0
)
local leftDoorTween = TweenService:Create(doormodel.LeftDoor, doorTweenInfo, {CFrame = doormodel.LeftDoorOpen.CFrame})
local rightDoorTween = TweenService:Create(doormodel.RightDoor, doorTweenInfo, {CFrame = doormodel.RightDoorOpen.CFrame})
doormodel.Keyhole.BrickColor = doormodel.Key.Value
doormodel.Keyhole.Touched:Connect(function(hit)
if hit.Parent:IsA(“Tool”) and hit.Parent.Name == “Key1” and hit.brickColor == doormodel.Key.Value then
doormodel.Keyhole:Destroy()
leftDoorTween:Play()
rightDoorTween:play()
end
end)
"
Cosnez
(Cosnez)
June 15, 2021, 8:15pm
#5
im trying to make it where after i touch the pedestal with the key the copyed version of it goes on the pedestal making it look like i placed it down
Can’t you make the key a model that is invisible on the door.
Then, you can run the function and just change the transparency of the key, when the tool touches it.
Cosnez
(Cosnez)
June 15, 2021, 8:19pm
#7
Oh lol Dident think of that can u help me a bit more I’m not really good at scripting and where to put it
Cosnez
(Cosnez)
June 15, 2021, 8:19pm
#8
Ok the handle dup is now in the model what I do now
doormodel.Keyhole.Touched:Connect(function(hit)
if hit.Parent:IsA(“Tool”) and hit.Parent.Name == “Key1” and hit.brickColor == doormodel.Key.Value then
--referencing where the invisible key model is--.Transparency = 0
end
end)
Cosnez
(Cosnez)
June 15, 2021, 8:23pm
#10
It said HandleDup is not a valid member of workspace
Cosnez
(Cosnez)
June 15, 2021, 8:24pm
#11
Wait I know why let me try hold up
Do local HandleDup = game.Workspace.HandleDup
Is “HandleDup” in workspace?
1 Like
Cosnez
(Cosnez)
June 15, 2021, 8:25pm
#13
It worked 2 more things how do I make it where the key destroys after I open the door and make it click to open door instead of touch
You’re wanting the door to open once the key is inserted into the key hole, correct?
–Referencing where the key is–:Destroy()
Cosnez
(Cosnez)
June 15, 2021, 8:28pm
#16
Yea how do I make it where the key leaves the inventory after
Cosnez
(Cosnez)
June 15, 2021, 8:28pm
#17
I got it figured out already but thanks
Reference where the tool actually is first.
So, for example:
hit.Parent
Then to remove it do:
hit.Parent:Destroy()
That’s great to hear, at least you’re learning!
Cosnez
(Cosnez)
June 15, 2021, 8:31pm
#20
Alright what about the click instead of touch