On the server, you could keep track of whenever a player equips and unequips tools. If a player equips a tool that you classify as metal and 10 seconds later, that specific tool instance is still equipped, spawn lightning on the player.
local runService = game:GetService('RunService')
local tool = script.Parent
local timeHeld = 0
local equipped = false
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)
runService.Heartbeat:Connect(function(deltaTime)
if equipped then
timeHeld += deltaTime
if timeHeld >= 10 then -- Set this to time before lightning strike in seconds
-- Strike the player with lightning
end
else
timeHeld = 0
end
end)
This is an interesting question. You could just increase the probability of being struck by lightning the longer the player has the item out. And then decrease the chance once the item is put away or completely remove the chance if you don’t want a lightning strike to be possible once the item is put away.
I’m not aware of how to make an actual lightning strike. @evaera Is pretty knowledgeable regarding that though. It’s a pretty nice attention to detail though.
You could easily just tween the lightning strike and set each tweeninfo to have like 0.1 delay for the first, 0.15 delay for the second and so on so it slowly goes down to the floor if yk what I mean, and you could maybe for a split second turn it neon.
Yeah heres the script but where it makes the lightning sort of “appear”
put the lightning in replicated storage
local runService = game:GetService('RunService')
local tool = script.Parent
local lightning = game.ReplicatedStorage.Lightning --replace with the name and location of your lightning
local timeHeld = 0
local equipped = false
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)
runService.Heartbeat:Connect(function(deltaTime)
if equipped then
timeHeld += deltaTime
if timeHeld >= 10 then -- Set this to time before lightning strike in seconds
lightning.Parent = game.Workspace
lightning.Transparency = 0
wait(0.1)
lightning.Transparency = 1
lightning.Parent = game.ReplicatedStorage
end
else
timeHeld = 0
end
end)