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

How do I make a tool incapable of being selected for an amount of time?{Solved. Thanks!}

How would I make it so that for 30 seconds, a tool couldn't be selected, then for 45 seconds, the tool could be selected, in a never ending loop? Thanks!

2 answers

✓ Accepted answer

If you don't want the tool visible in the backpack, just keep the tool in the lighting, then have the script move the tool into the backpack after a specific amount of time has passed. Like so:

--PUT THIS SCRIPT IN THE PLAYER

wait(30) --Waits 30 seconds
local Tool = Lighting["PUT TOOL NAME HERE"]:Clone() --Clones the tool
Tool.Parent = Player.Backpack --Puts the tool in the backpack of Player
wait(45) --Waits 45 seconds
Tool:Destroy() --Removes the tool

However, if you want the tool to be visible in the backpack, you would have a value in the tool called "CanSelect" or something like that, and have the equipped function of the tool check to see if that value is true, and if it isn't, then it deselects the tool. Like so:

--PUT THIS SCRIPT IN THE TOOL

local Player = game.Players.LocalPlayer --This gets the player that the script is in
function onEquipped()
	if (not Tool.CanSelect.Value) then
		Player.Character.Humanoid:UnequipTools()
		break
	end
	--Code here
end

You can have an external script change the value of "CanSelect" after a set time

4 comments

0

Where would I put the script on top?

0

Why lighting?

0

Just put it in workspace I believe. But what is "Player" in the Player.Backpack?

0

I edited the question

Is it in a Gui? If it is, I could help you out.

Put this script in the Gui.

Put the tool in Lighting.

while true do

if script.Parent.MouseButton1Click then
game.Lighting.TOOLNAME:clone().Parent = backpack
end
	script.Parent.Visible = false
	wait(45)
	script.Parent.Visible = true
	wait(30)
	script.Parent.Visible = false
	wait(45)
end

1 comment

0

I have a GUI shop, but the tool itself would be in the players backpack.

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