Hello developers!
I’m currently developming a horror imersive game about the backrooms, now I’m developming a monster which actives when a player gets nearby it. The way that I’ve found it’s totally uncurrate, I’m trying to achieve a window monster that opens curtains when you’re nearby, and closes when there’s no player nearby and a jumpscare(I’ll add that later):
(Ignore the other monster)
The window is closing and oppening and the audio is very buggy, here’s a part of my code:
local tween = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear)
local info1 = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
local isOpened = false
local bool = false
local bool1 = false
script.Parent.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if h and h.Health > 0 and isOpened == false and game.Players:GetPlayerFromCharacter(hit.Parent) and bool == false then
bool = true
local curtain1 = script.Parent.Parent.Curtain
local Monster = script.Parent.Parent.Window
local curtain2 = script.Parent.Parent.Curtain1
tween:Create(curtain1, info, {Size = Vector3.new(1.105, 5.502, 0.682)}):Play()
tween:Create(curtain1, info, {Position = Vector3.new(67.325, 189.893, -1126.736)}):Play()
script.Parent["Slide Curtain 2"]:Play()
tween:Create(curtain2, info, {Size = Vector3.new(0.895, 5.502, 0.682)}):Play()
tween:Create(curtain2, info, {Position = Vector3.new(67.325, 189.893, -1132.704)}):Play()
local anim = script.Window
local track = Monster.Humanoid.Animator:LoadAnimation(anim)
track:Play()
track:GetMarkerReachedSignal("Windowtap"):Connect(function()
script.Parent["Glass window tap"]:Play()
end)
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if bool1 == false then
bool1 = true
local amountTouching = script.Parent:GetTouchingParts()
for i, v in pairs(amountTouching) do
if i > 0 then
if v.Parent:FindFirstChildWhichIsA("Humanoid") and game.Players:GetPlayerFromCharacter(v.Parent) then
return
else
print(i, v, bool1, bool)
bool = false
local curtain1 = script.Parent.Parent.Curtain
local Monster = script.Parent.Parent.Window
local curtain2 = script.Parent.Parent.Curtain1
tween:Create(curtain1, info1, {Size = Vector3.new(3.505, 5.502, 0.682)}):Play()
tween:Create(curtain1, info1, {Position = Vector3.new(67.325, 189.893, -1127.936)}):Play()
script.Parent["Slide Curtain 2"]:Play()
tween:Create(curtain2, info1, {Size = Vector3.new(3.695, 5.502, 0.682)}):Play()
local lastTween = tween:Create(curtain2, info1, {Position = Vector3.new(67.325, 189.893, -1131.304)})
local anim = script.Window
lastTween:Play()
local track = Monster.Humanoid.Animator:LoadAnimation(anim)
track:Stop()
lastTween.Completed:Connect(function()
bool1 = false
end)
end
end
end
end
end)
How it works: