I’m currently working on a “e to interact” script, but the way it works currently is it only works with one model (a wardrobe) to make it open and close. What I want is the script to work with every wardrobes in the workspace without having to make a script for every single one of them.
This is what I have so far : (sorry for the messed up code)
local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild(“HumanoidRootPart”)
local UIS = game:GetService(“UserInputService”)
local Part = game.Workspace.wardrobe.Detector
local tweenService = game:GetService(“TweenService”);
local open = falseUIS.InputBegan:connect(function(keycode)
if keycode.keyCode == Enum.KeyCode.E thenlocal tweenInfo = TweenInfo.new(
1, – time
Enum.EasingStyle.Linear, – style
Enum.EasingDirection.Out, – direction
0, – repeat count
false, – reverses
0 – delaytime
);if (Part.Position - HumanoidRootPart.Position).magnitude < 20 then if open == false then open = true local tween = tweenService:Create(Part.Parent.Door1, tweenInfo, {CFrame = Part.Parent.Door1Open.CFrame}); tween:Play() else open = false local tween = tweenService:Create(Part.Parent.Door1, tweenInfo, {CFrame = Part.Parent.Door1Closed.CFrame}); tween:Play() end end
end
end)
As you can see the “Part” value is one of the wardrobes, it’s probably inefficient and I’d like it to take in account all of the models called “wardrobe”