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

Tool doesn't detect being used?

I have this script which clones a stored object then launches it out of a tool. However it does not work. it returns with no errors and a simple printing test shows that it just stops at line 5 when the item is loaded and then doesn't do anything else. I have tried the script in both regular and local script types to the same result. I have some other scripts in my game that clone stuff using a local script from the replicated storage without first getting the replicated storage service that are very similar to what I've done below to get 'arrow'.

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bullet = game.ReplicatedStorage.bullets.arrow
--it stops here

function pew()
--doesn't do anything in here
local arrow = bullet:clone() --all items are properly named and in the correct area
arrow.Parent = tool 
game:GetService("Debris"):AddItem(arrow, 2)
arrow.CFrame = CFrame.new(tool.Handle.Position, mouse.Hit.p)
local v = Instance.new ("BodyVelocity", arrow)
v.velocity = arrow.CFrame.lookVector *90
v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
end

 
tool.Activated:connect(pew)

The only thing I can think of is that 'tool.Activated' isn't like a click detector, but I don't really have any simple ideas to get the tool to detect when you click with it in hand. I've determined this from how the arrow should at the very least spawn when I click with the tool.

Any ideas how to fix this?

2 comments

0

Do you have filtering enabled?

0

I have manulactivationonly, archivable, and requireshandle checked on the tool. I also have state enabled. I do not know about filtering though

1 answer

✓ Accepted answer

Your problem is you have ManualActivationOnly checked, this means mouse clicks will not fire Activated.

1 comment

0

oh, lol. thanks again sean, you're the best

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