For context, I want to make a lava part appear in a certain location when V is pressed using lighting. I manage to clone the part and the script but the script does not work
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local debounce = false
local mouse = player:GetMouse()
userInputService.InputBegan:Connect(function(Input , IsTyping)
if not IsTyping then
if not debounce then
debounce = true
if Input.KeyCode == Enum.KeyCode.V then -- Up to this point is reading the input from player
game.Lighting.Lava:clone().Parent = game.Workspace -- Duplicated the part but not the script
game.Workspace.Lava:GetChildren() -- I attempt to get the script as a child but still doesn't work
wait(1)
game.Workspace.Lava:Destroy() -- Makes the lava disappear shortly after
end
wait(1)
debounce = false
end
end
end)
^^^ This is the script for cloning the part but the script does not work
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then -- if a humanoid exists, then
humanoid.Health = 0 -- damage the humanoid
end
end
script.Parent.Touched:connect(onTouch)
^^^^^ The script for the lava part However the script works fine when I use it as a normal part and not cloned (I have checked if it is in the part and it is)

3 comments
Unless you know the answer, don't spend time investigating for this cause. I found a work around that does what I do in a different way and I do not need the fix anymore/
Why is the lava part in lighting rather than workspace?
It's because you cloned a Script from a LocalScript