Hi! My problem is that I made a system where you can breach doors with a "Breaching Charge" item. You would press E on a door to blow it up. There is a local script in the tool that handles user inputs, a remoteEvent in replicatedStorage and a script in a model of serverScriptService
localScript
local UserInputService = game:GetService("UserInputService") local function onInputEnded(inputObject, gameProcessedEvent) -- First check if the 'gameProcessedEvent' is true -- This indicates that another script had already processed the input, so this one can be ignored if gameProcessedEvent then return end -- Next, check that the input was a keyboard event if inputObject.UserInputType == Enum.UserInputType.Keyboard then print("A key was released: " .. inputObject.KeyCode.Name) if inputObject.KeyCode.Name == "E" then if script.Parent.IsEquipped.Value == true then local doorRadius = 10 local position = script.Parent.Parent.PrimaryPart.Position for i,player in pairs(game.Workspace.BlastDoors:GetChildren()) do local distance = (player.Position - position).magnitude if distance < doorRadius and player.Picked.Value ~= true then --Vector3 can be the Position property of a part if you want. print(player.Name..'is within radius') print("pick") game.ReplicatedStorage.ExplodeDoor:FireServer(player) break end end end end end end UserInputService.InputEnded:Connect(onInputEnded)
script
print("load") function pick(plr, door) print("exploding") if #game.Teams.Police:GetPlayers() > 0 then print("is there a cop? yes") plr.Charcter.BreachingCharge:Destroy() print(plr) print(door) plr.Backpack.Hostile.Value = true local Expl = Instance.new("Explosion") Expl.DestroyJointRadiusPercent = 0 Expl.Position = door.Position Expl.Parent = door door.Picked.Value = true door.Transparency = 1 door.CanCollide = false door.imagePart.BillboardGui.TextLabel.Visible = false wait(180) door.Picked.Value = false door.Transparency = 0 door.CanCollide = true door.imagePart.BillboardGui.TextLabel.Visible = true end end game.ReplicatedStorage.ExplodeDoor.OnServerEvent:Connect(pick)