i tried to make some part explode if the player clicks on the e button on their keyboard but it didn’t work, it’s on localscript, i also tried with a server script but also didn’t work, i also removed the if gameprocessedevent == true but it still didn’t work
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent == true then
if input.KeyCode == Enum.KeyCode.E then
Instance.new("Explosion", workspace.Part)
end
end
end)
I just tested the following code in an empty baseplate and it worked fine:
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
Instance.new("Explosion", workspace.Part)
end
end)
You might be creating the explosion but not seeing it because it’s by default spawned at 0,0,0. After creating it, set it’s position to the part’s position like this
local explosion = Instance.new("Explosion", workspace.Part)
explosion .position = workspace.Part.Position
Also, you should be checking if gameProcessedEvent is False, not True.
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then -- you want this to be false, not true
if input.KeyCode == Enum.KeyCode.E then
local explosion = Instance.new("Explosion") -- we'll need to do a few things
explosion.Position = workspace.Part.Position
explosion.Parent = workspace.Part
end
end
end)
Something like this should work in a client script
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
wait(0.1)
print("explosion")
local ex = Instance.new("Explosion")
ex.Parent = game.Workspace.Part
ex.Position = game.Workspace.Part.Position
end
end)