I keep getting an error on the following code that says Torso is a nil value, which does not make sense to me. This is part of a time bomb weapon. When the bomb hits a player, I want it to float in front of them for a few second to build suspense before exploding. It sticks to the player's torso as intended, so my idea was that if the torso's CFrame was changed (the player moves) then the bomb would change to always be in front of the torso. Maybe there is an easier way to do this without running a "Changed" function over and over again, but I'm out of ideas. Let me know if you want to see the entire code.
local function OnTouched(otherPart) if otherPart.Parent:findFirstChild("Humanoid") then if Rocket and otherPart then Torso = otherPart.Parent:findFirstChild("Torso") dir = Torso.CFrame.lookVector pos = Torso.Position + (dir*3) Touched = true end end end Torso.Changed:connect(function() game.Workspace.Baseplate:Destroy() if Touched == true then Rocket.CFrame = CFrame.new(pos, pos + dir) end end) Rocket.Touched:connect(OnTouched)
The problem is R15 players don't have a child 'Torso' but both have HumanoidRootPart which I recommend using now of days.