local enabled = true Player = script.Parent.Parent character = Player.CharacterAdded:wait(); mouse = Player:GetMouse() run = game:GetService("RunService") Torso = Player.Character.Torso function onKeyDown(key) key = key:lower() if key == "e" then f = Instance.new("Fire") f.Color = Color3.new(0, 85, 255) f.SecondaryColor = Color3.new(0, 170, 255) f.Size = 15 f.Heat = 25 f.Parent = Torso weld = Instance.new("Weld") weld.Part0 = f --weld.C0 = f.CFrame:inverse() weld.Part1 = Torso weld.Parent = Torso y = Instance.new("BodyVelocity") y.maxForce = Vector3.new(5, 5, 5) y.velocity = Player.Character.Torso.CFrame.lookVector*80 y.Parent = Torso game.Debris:AddItem(f,weld,4) end end mouse.KeyDown:connect(onKeyDown)
21:23:49.410 - bad cast 21:23:49.410 - Script 'Players.kingalpha1.Backpack.Test', Line 18 21:23:49.411 - Stack End 21:23:49.411 - Disconnected event because of exception 21:25:06.524 - Auto-Saving...
this is a localscript btw.
A cast is a change of a value from one type to another.
A simple example in Lua is with strings and numbers through arithmetic; "8" * 1
turns "8"
into 8
and then performs the multiplication.
"Bad cast" is referring to the fact that it wasn't able to turn the value into the type it wanted.
Namely, that it can't turn Fire
into a BasePart
when you set Part0
.
Fire objects aren't welded to parts. They are just parented to them.
As to the remainder of the error, "disconnected due to exception":
"exception" is another name for error; when a function connected to an event errors, ROBLOX stops firing the event for that function; this message indicates that behavior.