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

How do I make it so my script only works when someone is holding a certain tool?

Asked by 5 years ago

I'm trying to fix something which is taking me ages, basically- I'm trying to make it so that a script of mine only works when I have a certain tool in my hand.


model = script.Parent.Parent backup = model:clone() enabled = true function regenerate() model:remove() wait(1)-- model = backup:clone() model.Parent = game.Workspace model:makeJoints() script.Disabled = true script.Parent.BrickColor = BrickColor.new(26)--Black wait(1) script.Parent.BrickColor = BrickColor.new(104)--Purple script.Disabled = false end function onHit(hit) if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and enabled then regenerate() end end script.Parent.Touched:connect(onHit)
0
(This script is supposed to regenerate a model when touching a part, it does that except I'm just trying to make it that it only regenerates when someone has a certain tool in their hand, and touches the brick that regenerates it. MrMultiMusic -9 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

it is easy. just do this,

copy this script to the moving part inside the tool. so script.Parent is the moving part in that tool. when it touches something, do that onHit() thing!

but then, you need to fix something. model is, of course, not a script.parent.parent anymore, it has to be derived from workspace.

0
The regeneration script & destroying tool in backpack works perfectly fine. Just the script needing to be activated with someone with the specific tool. If you were trying to say that, please explain it again because I don't understand what you genuinely mean. MrMultiMusic -9 — 5y
Ad

Answer this question