Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making a Custom tool for a client, How is this script not working?

player = game.Player.LocalPlayer
mouse = player:GetMouse()
firing = false
Canfire= true
reload = 5
damage = 35
rate = 5
script.Parent.Activated:connect(function()
	if Canfire == true then
		firing = true
		repeat local arrow = Instance.new("Part", workspace)
			arrow.CanCollide = false
			arrow.Shape = "Block"
			arrow.Size = Vector3.new(0.4,0.4,0.4)
			arrow.BrickColor = BrickColor.new(175,0,0)
			arrow.CFrame = CFrame.new(script.Parent.Handle.Position, mouse.Hit.p)
			local v = Instance.new("BodyVelocity", arrow)
			v.Velocity = arrow.CFrame.lookVector*50
			game.Debris:AddItem(arrow,15)
			arrow.Touched:connect(function(hit)
				if hit.Parent ~= player.Character and hit.Parent:FindFirstChild("Humanoid")
					then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
					arrow:Destroy()
			end
			end)
		until firing == false
	end
	
end)
script.Parent.Deactivated:connect(function()
	if firing == true then
		firing = false
	end
end)
mouse.Keydown:connect(function(key)
	Canfire = false
	wait(reload)
	Canfire = true
end)

That is my script for firing from a Union Handled Tool, I have no idea what is wrong with it, I am a horrid scripter.

3 comments

0

Format your code in code block, please.

0

Does it give any errors in studio output?

0

Nothing but Player is not a valid member of DataModel and Script analysis came up nothing.

1 answer

This is not an answer it is an correction.

When posting on this site all of your code should be in a code block

Also everything should be on separate lines and tabbed.

Now maybe this would make it easy to find your own error.

player = game.Player.LocalPlayer
mouse = player:GetMouse()
firing = false 
Canfire= true
reload = 5 
damage = 35 
rate = 5 

script.Parent.Activated:connect(function() 
	if Canfire == true then 
		firing = true 
		repeat 
			local arrow = Instance.new("Part", workspace) 
			arrow.CanCollide = false 
			arrow.Shape = "Block" 
			arrow.Size = Vector3.new(0.4,0.4,0.4) 
			arrow.BrickColor = "Persimmon" 
			arrow.CFrame = CFrame.new(script.Parent.Handle.Position, mouse.Hit.p) 
			local v = Instance.new("BodyVelocity", arrow) 
			v.Velocity = arrow.CFrame.lookVector*50 
			game.Debris:AddItem(arrow,15) 
			arrow.Touched:connect(function(hit)
				if hit.Parent ~= player.Character and hit.Parent:FindFirstChild("Humanoid") then
					hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
					arrow:Destroy() 
				end
			end)
		until firing == false 
	end
end) 

script.Parent.Deactivated:connect(function() 
	if firing == true then 
		firing = false 
	end 
end) 

mouse.Keydown:connect(function(key)
	Canfire = false
	wait(reload)
	Canfire = true
end)

1 comment

0

kk I'm a little new to this so.

This discussion is preserved as it was. New answers, comments, and votes are closed.