So I was wondering if anybody could explain why studio crashes whenever I specifically use this function, and try to put arguments into it. It never crashed before, but for some reason now all of a sudden it crashes whenever I try to use it and put an argument into it. (This code is quite messy, I know. But if studio crashed at debugging messy code, this would be a much more common issue for all of us…)
This does not happen when:
- The function doesn’t exist/commented out completely
- All but one specific block of the code is commented out
Problem block
Whenever I comment out this specific block, studio works just fine.
local Tagged = {}
Car.Hitbox.Touched:Connect(function(otherPart)
if otherPart:IsAncestorOf(Car) then return end
if Car.AssemblyLinearVelocity.Magnitude < 40 then
Car.Hitbox:Destroy()
return
end
-- Hit people that are hit by the hitbox during a high speed explosion
if isValidCharacter(otherPart) then
print("Hit " .. otherPart.Parent.Name)
local HitModel = otherPart.Parent
local isNPC = HitModel:FindFirstChild("AutoJumper", true)
local isPlayer = Players:GetPlayerFromCharacter(HitModel)
local DamageModule = HitModel:FindFirstChild("DamageModule", true)
table.insert(Tagged, HitModel)
-- Random launch directions
local randomX = math.random() * 2 - 1
local randomZ = math.random() * 2 - 1
local upwardComponent = Vector3.new(0, 1, 0)
local horizontalComponent = Vector3.new(randomX, 0, randomZ).Unit
local impulseDirection = horizontalComponent + upwardComponent
local impulseMagnitude = 400
impulseDirection = impulseDirection.Unit
local impulse = impulseDirection * impulseMagnitude
local Humanoid = HitModel:FindFirstChild("Humanoid")
if isNPC and isPlayer then
Humanoid.Jump = true
end
-- Depending on what they are, either 400 damage for NPCs is done, or only 50 for players
if DamageModule and isNPC then
DamageModule = require(DamageModule)
DamageModule.sendDamage(100, "Special", false, "Launch")
if Humanoid then
Humanoid.Died:Connect(function()
delay(0.04, function()
if HitModel.PrimaryPart then
HitModel.PrimaryPart.Anchored = false
HitModel.PrimaryPart:ApplyImpulse(impulse)
end
end)
end)
end
elseif isPlayer then
Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)
Humanoid.PlatformStand = true
delay(3, function()
Humanoid.PlatformStand = false
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end)
Humanoid:TakeDamage(25)
else
Humanoid:TakeDamage(100)
end
end
end)
While the code is reasonably horrible and if I were studio, I would probably want to do the same thing, why would it crash from trying to use an argument? Is it something about the argument’s expected properties?
(For reference, Car
is usually a meshpart or some other form of a BasePart
with a few inheritied thing like a Hitbox
part)
Quick edit: I notice that whenever I explicitly state Car is a BasePart
the crash doesn’t happen. I feel like it’s further evidence its something about its collected properties causing it.
local function explodeCar(Car: BasePart)...
Extensions seemed unrelated to the crash.
Studio Information
Tag | Info |
---|---|
Version | 0.645.1.6450668 (64bit) |
Latest version available | 0.645.1.6450668 |
Beta Information
Beta Name | Enrolled |
---|---|
Assistant Preview | True |
Avatar Auto-Setup Beta | False |
Dragger QoL Improvements | True |
EditableImage and EditableMesh | True |
Face Capture | True |
Gamepad Emulator | True |
Import Queue | True |
Improved Constraint Tool | True |
Improved Mass Properties | True |
Live Animation Creator | True |
Multilayer Wrap Fix | True |
New Luau type Solver | False |
New Studio Camera Controls | True |
Next Gen Studio Preview | True |
Preferred Text Size Setting | True |
Scripts Are Non-Strict by Default | True |
Texture Generator | True |
UIDragDetectors | True |
Updated Roblox Controls | True |
Video Uploads | True |
Operating System Specifications
Tag | Info |
---|---|
OS Name | Microsoft Windows 11 Home |
Version | 10.0.22631 Build 22631 |
Processor | AMD Ryzen 5 5500U with Radeon Graphics, 2100 Mhz, 6 Core(s), 12 Logical Processor(s) |
Installed Physical Memory (RAM) | 16.0 GB |