I'm using a local script in my vehicle to spawn bullets and it works with no issue. However, when I try to clone a disabled script to put it into the spawned bullet and enable it, it won't work, even when the script icon shows it's enabled inside the bullet.
Here's the part in my local script to spawn the bullet
mouse.KeyDown:connect(function(key)
if key == "f" then
print("pressed f")
local bullet = Instance.new("Part")
bullet.Size = Vector3.new(3,3,3)
bullet.BrickColor = BrickColor.new("Black")
bullet.Name = "bullet"
bullet.CustomPhysicalProperties = PhysicalProperties.new(0,0,0,0,0)
bullet.CFrame = script.Parent.gun.muzzle.CFrame * CFrame.new(0,0,-10)
local force = Instance.new("BodyVelocity")
force.Parent = bullet
force.Name = "Move"
force.velocity = script.Parent.gun.muzzle.CFrame.lookVector * 750
--below is where the problem starts i think
local new_script = script.Parent.gunscript2:clone()
new_script.Disabled = false
new_script.Parent = bullet
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = bullet
bullet.Parent = workspace
end
end)
and here's the script that is cloned and placed into the bullet
function onTouched(hit)
print ('bullet hit')
script.Parent:Destroy()
end
script.Parent.Touched:connect(onTouched)
I get no errors in the console and the bullet script works when I have it isolated in the workspace instead of it being cloned and such.
