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

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

Asked by 3 years ago
Edited 3 years ago

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
0
Ping, I replied Xapelize 2658 — 3y

1 answer

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago

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

0
its located in starter player scripts thecoolguy436 38 — 3y
0
Well, parent the script inside the tool and change line 7 to the code I gave on the answer Xapelize 2658 — 3y
0
thank you but why does this work? thecoolguy436 38 — 3y
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. imKirda 4491 — 3y
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. Antelear 185 — 3y
Ad

Answer this question