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

How to make this handle dissappear after touch?

local player = game.Players.LocalPlayer
local handle = script.Parent.Handle
local debounce = false
handle.Touched:Connect(function(hit)
    if not debounce and hit and hit.Parent.Humanoid then
        debounce = true
        hit.Parent.Humanoid:TakeDamage(40)
       wait(10)
       debounce = false
    end
end)

This is a local script called Damage in my tool How would I make the handle disappear after hit

Also please feel free for tips and advice, will gladly accept them.

4 comments

0

fix ur lua tags

0

can you reformat your question?

0

well after hit or damage, either put Handle.Transparency = 0 or Handle:Destroy()

1 answer

Your code wont replicate; you are using a localscript to damage which will not work but here Add a remote event into your tool and a Serverscript.

LocalScript:

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local event = tool:WaitForChild("RemoteEvent")
local uis = game:GetService("UserInputService")
local canhit = true
uis.InputBegan:Connect(function(Input,gameProcessed)
	if not gameProcessed then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 and canhit then
			event:FireServer()
			canhit = false
			wait(10)
			canhit = true
		end
	end
end)

Paste this code into your serverscript

Server Script:

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local event = handle:WaitForChild("RemoteEvent")
local canhit = true
local damaged = false
event.OnServerEvent:Connect(function(player,arg1,arg2)
	if canhit then
		Handle.Touched:Connect(function(hit)
			local hum = hi.Parent:FindFirstChildOfClass("Humanoid")
			if hum and not damaged then
				hum:TakeDamage(40)
				damaged = true
				handle.Transparency = 1
			end
		end)
		wait(10)
		damaged = false
		canhit = true
		handle.Transparency = 0
	end
end)

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