I want to create an explosion anywhere I click with my mouse. You can only get the mouse from local scripts, so I needed to make a remote event. So when I click it fires the server with my mouses position and creates an explosion in that area.
local script:
local player = game.Players.LocalPlayer
local repStorage = game:GetService(“ReplicatedStorage”)
local bomb = repStorage:WaitForChild(“Bomb”)
local bombRemote = repStorage:WaitForChild(“BombRemote”)
local db = false
local mouse = player:GetMouse()
mouse.Button1Up:Connect(function()
if db == false then
db = true
bombRemote:FireServer(mouse.Hit)
end
end)
Server Script:
local repStorage = game:GetService(“ReplicatedStorage”)
local bombRemote = repStorage:WaitForChild(“BombRemote”)bombRemote.OnServerEvent:Connect(function(…)
local Tuple = {…}
local player = Tuple[1]
local character = player.Character
local hit = Tuple[2]
local bomb = Instance.new(“Explosion”)
bomb.Position = hit.Position
bomb.Parent = game.Workspace
end)
I fire the server when I click, but only on the first click. When I try to click again it does nothing.
Any ideas on how to fix this?