Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool doesn't detect being used?

Asked by
Smunkey 95
8 years ago

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?

0
Do you have filtering enabled? GoldenPhysics 474 — 8y
0
I have manulactivationonly, archivable, and requireshandle checked on the tool. I also have state enabled. I do not know about filtering though Smunkey 95 — 8y

1 answer

Log in to vote
1
Answered by
DevSean 270 Moderation Voter
8 years ago

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

0
oh, lol. thanks again sean, you're the best Smunkey 95 — 8y
Ad

Answer this question