What do you want to achieve? Keep it simple and clear!
I am making a bomberman type game and I’m trying to make a bomb appear at the player’s location when E is pressed
What is the issue? Include screenshots / videos if possible!
It doesn’t work, despite everything I’ve done. I do it through remote events. I’m fairly new to scripting
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did, but I found nothing that helped
Just in case, here’s the code
LocalScript:
local BombPlaceEvent = ReplicatedStorage:WaitForChild("BombPlaceEvent")
local UserInputService = game:GetService("UserInputService")
local ActionKey = Enum.KeyCode.E
local keysPressed = UserInputService:GetKeysPressed()
for _, key in ipairs(keysPressed) do
if (key.KeyCode == ActionKey) then
BombPlaceEvent:FireServer()
end
end
ServerScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BombPlaceEvent = ReplicatedStorage.BombPlaceEvent
local bombRS = ReplicatedStorage.Bomb
BombPlaceEvent.OnServerEvent:Connect(function(player)
local bomb = bombRS:Clone()
bomb.Parent = game.Workspace
bomb.Position = player.Character.HumanoidRootPart.CFrame
end)
local BombPlaceEvent = ReplicatedStorage:WaitForChild("BombPlaceEvent")
local UserInputService = game:GetService("UserInputService")
local ActionKey = Enum.KeyCode.E
UserInputService.InputBegan:connect(function(input)
if input.UserInputType == ActionKey then
BombPlaceEvent:FireServer()
end
end
replace this code with the one you got in the local script.
and replace the other code i gave you in the serverscript.