question, is the door supposed to Not Close but the other ones do?
Yeah, I didnāt add some code for it to close. Iāll write that and add it below:
Edit:
Replace the code in the module script named Interact with this:
local TweenService = game:GetService("TweenService")
local isOpen = false
local canInteract = true
local hasAllItems = false
local function interact(player, settingsFolder)
local requiredItems = settingsFolder.RequiredItems
local requiredItemsFolder = settingsFolder.RequiredItems
local multiUseItems = requiredItemsFolder.MultiUse
local singleUseItems = requiredItemsFolder.SingleUse
local movingPart = settingsFolder.MovingPart.Value
local initialCFrame = settingsFolder.FirstPositionPart.Value.CFrame
local finalCFrame = settingsFolder.SecondPositionPart.Value.CFrame
local itemsFolder = player:FindFirstChild("Items")
if not itemsFolder then
return false
end
if not hasAllItems then
hasAllItems = true
for _, child in ipairs(multiUseItems:GetChildren()) do
if not itemsFolder:FindFirstChild(child.Name) then
hasAllItems = false
end
end
for _, child in ipairs(singleUseItems:GetChildren()) do
local item = itemsFolder:FindFirstChild(child.Name)
if not item then
hasAllItems = false
else
item:Destroy()
child:Destroy()
end
end
end
if hasAllItems and canInteract then
canInteract = false
local goal
if isOpen then
goal = initialCFrame
else
goal = finalCFrame
end
local tween = TweenService:Create(movingPart, TweenInfo.new(0.5), {CFrame = goal})
tween:Play()
isOpen = not isOpen
local connection
connection = tween.Completed:Connect(function()
canInteract = true
connection:Disconnect()
tween:Destroy()
end)
end
end
return interact
Edit:
Youāll probably need to learn how to code to do that. There probably arenāt any models that do exact what you want, since itās pretty specific to your game.
TYSM!!
@PersonifiedPizza
I got a question, do you know how to make an NPC (a skinned mesh rig) Act like slender man
What I mean is the NPC Popping up at certain points in the map and as you progress and it can have jump scares as well.
for example Iām walking down a forest and I get jump scared by the NPC, BUT I dont get Killed or hurt if I touch the AI. Then I can get Chased at a certain point in the map (Flat area) and when I get caught I get Hurt or Killed.
Jumpscares can be like
Pop up
Gui
Sound
(All of those at random)
so basically 2 NPCās
1- Jumpscares you at times, and at CERTAIN time/Areas in the map
2- One that chases you and disapears after you get to a certain point, or after a certain amount of time (I personally want both depending on where I am at in the game same thing with jump scare (Depending where I am at.))
I just wanna know how this can be made possible and where I can learn to make it or find a model?
The code given doesnt work at all. I tested
I tested it and it worked. Hereās how you should set it up:
- Set up the door like normal
- Open the module script named āInteractā
- Select all the code inside it and paste it over
Are you getting errors or anything?
Edit:
No worries. Iād double check the values of the FirstPositionPart and the SecondPositionPart. Make sure that the FirstPositionPart is in the position+orientation of the closed state.
Here is a place file with a working door:
HGSD Example Door.rbxl (71.0 KB)
Edit:
@Officerbruh0987
If possible, could you send me a DM? Weāre not really suppose to bump topics this much.
I didnāt add a way to add sounds, though itās not that hard to add.
- Replace the Interact ModuleScriptās code with:
local TweenService = game:GetService("TweenService")
local isOpen = false
local canInteract = true
local hasAllItems = false
local sound = script:WaitForChild("Sound") -- Added sound reference
local function interact(player, settingsFolder)
local requiredItems = settingsFolder.RequiredItems
local requiredItemsFolder = settingsFolder.RequiredItems
local multiUseItems = requiredItemsFolder.MultiUse
local singleUseItems = requiredItemsFolder.SingleUse
local movingPart = settingsFolder.MovingPart.Value
local initialCFrame = settingsFolder.FirstPositionPart.Value.CFrame
local finalCFrame = settingsFolder.SecondPositionPart.Value.CFrame
local itemsFolder = player:FindFirstChild("Items")
if not itemsFolder then
return false
end
if not hasAllItems then
hasAllItems = true
for _, child in ipairs(multiUseItems:GetChildren()) do
if not itemsFolder:FindFirstChild(child.Name) then
hasAllItems = false
end
end
for _, child in ipairs(singleUseItems:GetChildren()) do
local item = itemsFolder:FindFirstChild(child.Name)
if not item then
hasAllItems = false
else
item:Destroy()
child:Destroy()
end
end
end
if hasAllItems and canInteract then
canInteract = false
local goal
if isOpen then
goal = initialCFrame
else
goal = finalCFrame
end
local tween = TweenService:Create(movingPart, TweenInfo.new(0.5), {CFrame = goal})
tween:Play()
isOpen = not isOpen
sound:Play() -- Added Play function
local connection
connection = tween.Completed:Connect(function()
canInteract = true
connection:Disconnect()
tween:Destroy()
end)
end
end
return interact
- Add a Sound to the Interact ModuleScript
- Name the Sound āSoundā
- Set the soundās content ID (specify with sound to play)
Let me know if the sound doesnāt play, I may have messed up the position of the sound in the hierarchy. I believe it should play as a global sound currently (same volume everywhere). To make it not global weād need to use an ObjectValue, which can be kind of confusing.
No worries. Itās not exactly a rule rule, itās just something that mods want people to do to stop topics from being bumped too much.
Have a system where you can store objects in another āBackpack Alternativeā such as a Folder
instance inside the Player name like āitemsā.
That way, have the script access that folder, and that folder would not be able to be like a Backpack or items inside the folder canāt be equipped nor unequipped.
lemme re-try it, I will see if I get any errors.
It is still not working and I tried the code from the other door and it still wont work.
Video:2022 01 23 16 24 41 - YouTube
(Replied to myself again Sighā¦)
It is still not working and I tried the code from the other door and it still wont work.
Video:2022 01 23 16 24 41 - YouTube
Sorry that I said the same thing but I replied to the wrong person on accident lol
It worked, thank you so much! Iāll let you know if I have any future questions about this.
question, what if I want to have no tools to unlock, would I just put no folders in the required Items? @PersonifiedPizza
also, can I have the a proximity Prompt for the Doors (to open and close) and to pick up objects (interactable items).
because I was looking at the code for the āInteractable Scriptā in the Door
Edit2: I just figured the Proximity Prompt one.
Edit3: i just figured out the no tool thingy I was asking
I figured everything out so I basically answered my own question, my bad.
Question, would there be a way I could add open/close sounds for the doors?
okay, thank you! and yes I will make a DM if I have any questions. Sorry, I didnt know about the rules of having a topic this long sorry.