Why wont this the function binded to an event fire?
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
01 | local UserInputService = game:GetService( "UserInputService" ) |
03 | local function onInputEnded(inputObject, gameProcessedEvent) |
06 | if gameProcessedEvent then return end |
08 | if inputObject.UserInputType = = Enum.UserInputType.Keyboard then |
09 | print ( "A key was released: " .. inputObject.KeyCode.Name) |
10 | if inputObject.KeyCode.Name = = "E" then |
11 | if script.Parent.IsEquipped.Value = = true then |
13 | local position = script.Parent.Parent.PrimaryPart.Position |
16 | for i,player in pairs (game.Workspace.BlastDoors:GetChildren()) do |
17 | local distance = (player.Position - position).magnitude |
18 | if distance < doorRadius and player.Picked.Value ~ = true then |
19 | print (player.Name.. 'is within radius' ) |
21 | game.ReplicatedStorage.ExplodeDoor:FireServer(player) |
35 | UserInputService.InputEnded:Connect(onInputEnded) |
script
02 | function pick(plr, door) |
04 | if #game.Teams.Police:GetPlayers() > 0 then |
05 | print ( "is there a cop? yes" ) |
06 | plr.Charcter.BreachingCharge:Destroy() |
09 | plr.Backpack.Hostile.Value = true |
10 | local Expl = Instance.new( "Explosion" ) |
11 | Expl.DestroyJointRadiusPercent = 0 |
12 | Expl.Position = door.Position |
14 | door.Picked.Value = true |
18 | door.CanCollide = false |
20 | door.imagePart.BillboardGui.TextLabel.Visible = false |
24 | door.Picked.Value = false |
28 | door.CanCollide = true |
30 | door.imagePart.BillboardGui.TextLabel.Visible = true |
36 | game.ReplicatedStorage.ExplodeDoor.OnServerEvent:Connect(pick) |