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

Why does this script work in workspace but not while being used as a tool?

This script works only when in the workspace but I need it to work while being used as a tool

Here is the script:

function crash(hit)
	if hit.Name == "Wheel" then
		hit.Parent.Parent:Destroy()
		print("Wheels gone")
	end
end

script.Parent.Touched:connect(crash)

13 comments

0

does it have to do with what script.Parent.Parent is referring to? make sure it still has the reference it needs

0

It's supposed to pop the wheels of a moving car but it only works when it's placed on the ground in workspace

0

what happens when u test it on tool

0

When I use it as tool it simply does nothing

0

any errors in output? can you send a link to an image of the car and its childs in explorer

0

rather than a touched event, you need an Activated event. tools are activated

0

No errors at all

1

@Spiritlotus Probs send that in Answers

0

you need to rewrite it so that on activation it does something to the wheel.

0

It doesn't really serve the purpose of being a tire popping tool then

0

I need it to pop any car tire that touches the part while the tool is being held

0

you could get the players mouse on tool.Activated. if the mouse.Hit is a wheel, then delete it. this should be enough to get you started, as this isnt a request site. accept my answer if all went well :)

0

or check if the Handle of the tool touched a wheel on activation

1 answer

✓ Accepted answer

when you click on a tool, the tools .Activated event is called. but it doesnt take in hit as a parameter, so this needs to be rewritten to fit your needs

as stated in the comments, upon activation you can check to see if the Handle touched a wheel.

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