yeah sorry but that souds helpful
Are you using a ProximityPrompt and script to open close the door?
it’s a clickdetector inside the door
instead of relying on animations ending, etc, you should make it so the “Hiding” value sets to true when you try to hide in a locker, after, 0.5 seconds, which would be what the door animation takes
that’s a simple solution, but there are more workarounds, using raycasts for example, if the attacker already noticed you before you hide (by raycasts), then the attacker should kill you
if there is no animation, because i still didn’t understand the final goal, then instead of using .touched I recommend region3, because .touched and touchended events are far from reliable
Yeah right now i’m trying to use touch events but I don’t know what region3 is
or an even better thing is to cast a ray inside the locker to check if there’s a player inside,
local playerIsInside (you’d get this by raycasting and checking if it hit the player)
if playerIsInside AND doorIsLocked then hiding = true end
Can I see the ClickDetector script, so I can make this work with what you have.
90% there …
local Info = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local event = Instance.new("BindableEvent")
local Door = script.Parent.Door
local OrigPos = Door.Center.CFrame
local TGP = script.Parent.ToGoPos.CFrame
local DoorMain = Door.MainDoor
local TweenedCompleted = "N/A"
local DoorStatus = "Closed"
local Debounce = false
local DoorClosed = script.Parent.DoorClosed
local function TweenModel(Model, CFrame)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = Model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
Model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local Tween = TweenService:Create(CFrameValue, Info, {Value = CFrame})
Tween:Play()
Tween.Completed:connect(function()
CFrameValue:Destroy()
TweenedCompleted = "Yes"
end)
while TweenedCompleted == "N/A" do
wait(0.1)
end
TweenedCompleted = "N/A"
end
script.Parent.Door.MainDoor.ClickDetector.MouseClick:Connect(function()
if DoorStatus == "Closed" and Debounce == false then
Debounce = true
DoorMain.Close:Play()
TweenModel(script.Parent.Door, TGP)
DoorStatus = "Opened"
DoorClosed.Value = true
Debounce = false
elseif DoorStatus == "Opened" and Debounce == false then
Debounce = true
DoorMain.Open:Play()
TweenModel(script.Parent.Door, OrigPos)
DoorStatus = "Closed"
DoorClosed.Value = false
Debounce = false
end
end)
Wow, you actually opened the door and not just went to a different open model.
Glad I asked!
I pretty much got it but I’m having problems with your door as I don’t have all that.
Is that a model I can get …
oh yeah I see it’s ok. Yeah i am not 100% responsible for this I had an earlier version that just snapped to a different open variation and that wasn’t up to my standards or something so I just tried to improv off of a door script. but yea any input you’ve had is helpful
I need that locker to work with … actually to just finish, I got the logic working.
Ok I got it … give me a few to put this all together
This is script is both in HidePart and OutsideHitBox, other than the 1st line …
outside = local locker = 0, inside = local locker = 1
locker = 1 is locker #1 and so on.
local locker = 1
script.Parent.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player == nil then return end
Player.Character:SetAttribute("Locker", locker)
end)
Changes to your script: (in the Toggle event part)
--//Toggle event//--
script.Parent.Door.MainDoor.ClickDetector.MouseClick:Connect(function(press)
if DoorStatus == "Closed" and Debounce == false then Debounce = true
DoorMain.Close:Play()
TweenModel(script.Parent.Door, TGP)
DoorStatus = "Opened"
DoorClosed.Value = true
local Player = press.Character
if Player:GetAttribute("Locker") > 0 then
print("hidden")
end
Debounce = false
elseif DoorStatus == "Opened" and Debounce == false then
Debounce = true
DoorMain.Open:Play()
TweenModel(script.Parent.Door, OrigPos)
DoorStatus = "Closed"
DoorClosed.Value = false
Debounce = false
end
end)
*Edit and add this under: local DoorClosed = script.Parent.DoorClosed
on the upper part of that script.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local Player = game.Workspace:WaitForChild(tostring(player))
Player:SetAttribute("Locker", 0)
end)
Now that that is all done … you could search through the players with one of them one script loops.
looking for if Player:GetAttribute(“Locker”) > 0 … the number will be what locker they are in … if they are not in a locker it will yield 0
This was super fun …thanks for tonight’s project!
Interesting. I will try this. Is the first part just one script inside the hide and exit parts? And the 2nd I only need to change the toggle event section? And you’re welcome thank you for helping me out with this
yep … but in the end it only prints: hidden and sets the attribute
read that last part …
Also that door is really hard to open up from the inside when you’re closed in.
AND make sure to set DoorClosed to true (maybe that don’t matter)
Ya, that matters. it will error if not (that ones on you)
It seems to error on me regardless
(function(press) <— you see that part
and DoorClosed = true … as in go set DoorClosed to true with a checkmark
I can open and close it when inside when i set it to true(hiding still isn’t ever true) but when outside if I close it it stays closed and gives me this error anyway even if doorclosed is true in studio
oh yeah I dont think theres anything to set it there
do you have the local locker = 1 and locker = 0 on the right hit boxes