Hello, I am trying to make a hiding spot for my game, but for some reason, the output put out an error.
Screenshot of the error
LocalScript
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent == false and input.UserInputType == Enum.UserInputType.Keyboard then
game.ReplicatedStorage.GoOutLocker:FireServer(input)
end
end)
Script
local Tween_Service = game:GetService("TweenService")
local dooropen = script.Parent.Parent.dooropen
local ProximityPrompt = script.Parent.ProximityPrompt
local PlayerHidden = script.Parent.Parent.PlayerHidden
local Hiding = script.Parent.Parent.Hiding
local Old_Position = script.Parent.CFrame
ProximityPrompt.Triggered:Connect(function(plr)
if Hiding.Value == false then
local HumanoidRootPart = plr.Character:WaitForChild("HumanoidRootPart")
local Humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
if Humanoid.Health < 1 then return end
if plr.Character:FindFirstChild("CantHide") then return end
ProximityPrompt.MaxActivationDistance = 0
PlayerHidden.Value = plr
Hiding.Value = true
local Canthide = Instance.new("BoolValue")
local Hidden = Instance.new("BoolValue")
Canthide.Name = "CantHide"
Hidden.Name = "Hidden"
Hidden.Parent = plr.Character
Canthide.Parent = plr.Character
script.Parent.Open:Play()
local Anim = Tween_Service:Create(script.Parent, TweenInfo.new(0.5), {CFrame = dooropen.CFrame})
Anim:Play()
Anim.Completed:Wait()
HumanoidRootPart.Anchored = true
plr.Character:PivotTo(script.Parent.Parent.Inside.CFrame)
task.wait(0.25)
local Anim = Tween_Service:Create(script.Parent, TweenInfo.new(0.5), {CFrame = Old_Position})
Anim:Play()
Anim.Completed:Wait()
script.Parent.Close:Play()
end
end)
game.ReplicatedStorage.GoOutLocker.OnServerEvent:Connect(function(plr, input)
if (input.KeyCode == Enum.KeyCode.W)
or (input.KeyCode == Enum.KeyCode.A)
or (input.KeyCode == Enum.KeyCode.S)
or (input.KeyCode == Enum.KeyCode.D)
then
local HumanoidRootPart = plr.Character:WaitForChild("HumanoidRootPart")
local Humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
if Humanoid.Health < 1 then return end
if plr ~= PlayerHidden.Value then return end
ProximityPrompt.MaxActivationDistance = 0
PlayerHidden.Value = plr
Hiding.Value = false
script.Parent.Open:Play()
local Anim = Tween_Service:Create(script.Parent, TweenInfo.new(0.5), {CFrame = dooropen.CFrame})
Anim:Play()
Anim.Completed:Wait()
HumanoidRootPart.Anchored = false
PlayerHidden.Value = nil
plr.Character:FindFirstChild("CantHide"):Destroy()
plr.Character:FindFirstChild("Hidden"):Destroy()
plr.Character:PivotTo(script.Parent.Parent.Inside.CFrame * CFrame.new(-5,0,0))
task.wait(0.25)
local Anim = Tween_Service:Create(script.Parent, TweenInfo.new(0.5), {CFrame = Old_Position})
Anim:Play()
Anim.Completed:Wait()
script.Parent.Close:Play()
task.wait(0.5)
ProximityPrompt.MaxActivationDistance = 10
end
end)