Hello, I'm Bladeor, and I am making a game called Mutiny. I need scripting help with a weapon I acquired from a friend. I need someone to help me change this function from a spawn a part and throw it forward script to a raycasting script. This is because this script works in Studio, but not in actual gameplay after I upload it.

Here is the function part of the script. There is much more script above and below it.

function fire(v)


	Tool.Handle.Fire:play()
	

	local vCharacter = Tool.Parent
	local vPlayer = game.Players:playerFromCharacter(vCharacter)

	local missile = Instance.new("Part")

        

	local spawnPos = vCharacter.PrimaryPart.Position
	


	spawnPos  = script.Parent.Shot.Position

		local spawnPos = vCharacter.Musket.Flame.Position

	spawnPos  = spawnPos + (v * 200)



	missile.Position = spawnPos
	missile.Size = Vector3.new(1,1,1)
	missile.Velocity = v * 800
	missile.BrickColor = BrickColor.new("Bright Blue")
	missile.Shape = 0.5
	missile.BottomSurface = 0
	missile.TopSurface = 0
	missile.Name = "Paintball"
	missile.Elasticity = 0
	missile.Reflectance = .1
	missile.Friction = .3


	local force = Instance.new("BodyForce")
	force.force = Vector3.new(0,100,0)
	force.Parent = missile

	
	local force = Instance.new("BodyForce")
	force.force = Vector3.new(0,missile:GetMass() * 1,0)
	force.Parent = missile

	local mesh = Instance.new("SpecialMesh")
	mesh.Scale = Vector3.new(.2,.2,.2)
	mesh.MeshType = "Sphere"
	mesh.Parent = missile

	local new_script = script.Parent.Bullet:clone()
	new_script.Disabled = false
	new_script.Parent = missile

	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = vPlayer
	creator_tag.Name = "creator"
	creator_tag.Parent = missile
	


	missile.Parent = game.Workspace
	

2 comments

0

I guess I should probably learn Raycast myself, as I'm working on guns for my survival game. >.<

0

That's a good idea!