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

im trying to get this to work only when the tool is equipped but delayed doesnt change?

the LocalScript is in starter player scripts

local rep = game.ReplicatedStorage
local mouseDetection = rep.MouseDetection
local UIS = game:GetService("UserInputService")
local delayed = false
local delayTime = 0
local equipped = false
local tool = game.StarterPack.Katana
tool.Equipped:Connect(function()
	equipped = true
end)
tool.Unequipped:Connect(function()
	equipped = false
end)
UIS.InputBegan:Connect(function(input)
	if delayed == false then
		if equipped == true and input.UserInputType == Enum.UserInputType.MouseButton1 then
			delayed = true
			mouseDetection:FireServer()
			if delayed == true then
				task.wait(delayTime)
				delayed = false
			end
		end
	end
end)
while true do
	wait(2)
	print(delayed)
end

1 comment

0

Ping, I replied

1 answer

✓ Accepted answer

Where is this script located? If it's inside the tool, make the line 7 to:

local tool = script.Parent

If you didn't, do it

5 comments

0

its located in starter player scripts

0

Well, parent the script inside the tool and change line 7 to the code I gave on the answer

0

thank you but why does this work?

0

because StarterPack is a container from which tools are cloned when you spawn, modifying them in StarterPack won't modify your current tools but the next time you spawn you will get the modified tools, tools that are cloned from StarterPack go into Player.Backpack and this script is inside the tool so script.Parent represents the cloned tool.

0

essentially, starterpack isn't the BACKPACK. the BACKPACK is in your PLAYERGUI. the GUI "BACKPACK" holds your TOOLS. the starterpack is a place where ANY tool inside there is given to EVERY player that joins automatically.

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