Hello there, we are working on an SCP game and right now we are trying to make the SCP (SCP-049 If you want to know) Randomly sit in a chair in his cell right now it tends to work a few times per test and then breaks after he sits down and gets out a few times.
Expected behaviour
NPC (Will be refereed as SCP) will be able to move to and sit down in the chair then be able to get out of the chair without error.
Observed behaviour
SCP Is able to sit and get out of the chair at least 4 - 5 times and then will return the error below.
Video of Observed behaviour
Below you will see it is able to sit a few times then it breaks. Sorry that its a long video
Error:
Text version of error:
13:53:59.673 An error ocurred while sitting the SCP, retrying! - Server - SCP-049:435
13:54:08.505 SCP failed to sit, retrying again. - Server - SCP-049:442
13:54:08.506 ERROR: Sit is not a valid member of MeshPart "Workspace.Wooden_Chair.Seat" - Server - SCP-049:448
13:54:09.009 Second method failed, Attempting to replace seat, debug texts incoming. - Server - SCP-049:452
13:54:09.011 Finished replacing seat. - Server - SCP-049:410
13:54:17.859 ServerScriptService.Game.Server.Systems.SCPs.049.Modules.SCP-049:464: Couldn't get the SCP to sit. - Server - SCP-049:464
13:54:17.859 Stack Begin - Studio
13:54:17.859 Script 'ServerScriptService.Game.Server.Systems.SCPs.049.Modules.SCP-049', Line 464 - function Sit049 - Studio - SCP-049:464
13:54:17.859 Script 'ServerScriptService.Game.Server.Systems.SCPs.049.Scripts.049', Line 332 - Studio - 049:332
13:54:17.859 Stack End
The sit function for 049:
local function ReplaceSeat(currentSeatPart: Seat)
local SeatParameters = {
Size = Vector3.new(2.935, 0.726, 2.975),
Position = Vector3.new(43.556, 1.851, 124.492)
}
local newSeatPart = Instance.new("Seat")
newSeatPart.Size = SeatParameters.Size
newSeatPart.Position = SeatParameters.Position
table.clear(SeatParameters)
currentSeatPart:Destroy()
seat = newSeatPart
newSeatPart.Parent = chair
newSeatPart.Anchored = true
newSeatPart.CanCollide = false
newSeatPart.Transparency = 1
warn("Finished replacing seat.")
return
end
function m.Sit049()
if moving then
warn("Tried to sit SCP-049 but SCP-049 is already moving somewhere else!")
return
elseif trackingPlayer then
warn("Tried to sit SCP-049 but SCP-049 is tracking a player!")
return
end
moving = true
m.Stop049Movement(true)
m.Move049(false, seat.Position, nil, false)
moving = false
if humanoid049.SeatPart == nil then
warn("An error ocurred while sitting the SCP, retrying!")
while humanoid049.SeatPart == nil and task.wait() do
m.Move049(false, sitFixPart.Position, nil, false)
m.Move049(false, seat.Position, nil, false)
if humanoid049.SeatPart then break end
warn("SCP failed to sit, retrying again.")
local success, response = pcall(function()
seat:Sit(humanoid049)
end)
if success then break else warn("ERROR: "..response) end
task.wait(0.5)
if humanoid049.SeatPart then break end
warn("Second method failed, Attempting to replace seat, debug texts incoming.")
ReplaceSeat(seat)
if humanoid049.SeatPart == nil then
m.Move049(false, sitFixPart.Position, nil, false)
m.Move049(false, seat.Position, nil, false)
else
warn("HUMANOID SEATPART FOUND: "..humanoid049.SeatPart)
break
end
if humanoid049.SeatPart == nil then
error("Couldn't get the SCP to sit.")
return
end
end
end
print("SCP-049 sat succesfully!")
return
end
Code executing the function:
while task.wait() do
if isInContainment.Value == true then
local moveChance = math.random(1, 100)
warn("Move chance of moving SCP 049 in his cell: "..moveChance)
warn("Move chance WITH multiplier: "..moveChance - chanceMultiplier)
if moveChance - chanceMultiplier <= 30 then
chanceMultiplier = 0
warn("Moving 049 around waypoints.")
print("Is SCP currently sitting? "..tostring(isSat))
module049.Move049(true, nil, nil, nil, isSat)
isSat = false
warn("Did the SCP move?: Yes.")
debounceRandomMoveContainment = math.random(4, 5)
warn("Time to wait before retrying to move the SCP: "..debounceRandomMoveContainment)
for i = 1, debounceRandomMoveContainment do
task.wait(1)
print("Retrying to move the SCP in "..debounceRandomMoveContainment - i.." seconds.")
end
else
chanceMultiplier += 5
local sitChance = math.random(1, 30)
warn("Sit chance: "..sitChance)
if not isSat then
if sitChance >= 15 then
isSat = true
module049.Sit049()
end
end
warn("Did the SCP move?: No.")
warn("Did the SCP sit?: ".. if isSat then "Yes." else "No.")
debounceRandomMoveContainment = math.random(4, 5)
warn("Time to wait before retrying to move the SCP: "..debounceRandomMoveContainment)
for i = 1, debounceRandomMoveContainment do
task.wait(1)
print("Retrying to move the SCP in "..debounceRandomMoveContainment - i.." seconds.")
end
end
elseif isInContainment.Value == false then
print("Waiting!")
task.wait()
end
end