I have 2 scripts in a tool local and normal
Main(normal):
local tool = script.Parent local handle = tool:WaitForChild("Handle") local Storage = game:GetService("ReplicatedStorage") local remoteEvent = Storage:WaitForChild("Explosion") local at = 2 local function explo(player) tool.Activated:Connect(function() local mouse = player:GetMouse() local expo = Instance.new("Explosion", workspace) expo.Position = mouse.Hit.Position wait(at) expo:Destroy() end) end remoteEvent.onServerEvent:Connect(explo)
local:
local tool = script.Parent local handle = tool:WaitForChild("Handle") local Player = game.Players.LocalPlayer local mouse = Player:GetMouse() local codwn = false local at = 1 local qp = false tool.Equipped:Connect(function() qp = true if qp ~= false then mouse.Button1Down:Connect(function() if codwn ~= true then codwn = true tool:Activate() wait(at) tool:Deactivate() codwn = false end end) end end) tool.Deactivated:Connect(function() qp = false end)
I tried to make it work with remote event called Explosion but didn't seem to work.
In your Tool.Equipped section, move
if qp ~= false then mouse.Button1Down:Connect(function() if codwn ~= true then codwn = true tool:Activate() wait(at) tool:Deactivate() codwn = false end end) end
outside of the connection.
For the server, the function variables should be player, hitp. Then on the client, instead of Tool:Activate() fire the remote with the arguments mouse.Hit.Position. (game.ReplicatedStorage.Explosion:FireServer(mouse.Hit.Position)
Make sure to remove Tool:Deactivate()!
Your server should look like this:
local function explo(player, hitp) local expo = Instance.new("Explosion", workspace) expo.Position = hitp wait(at) expo:Destroy() end
and your client should look like this:
if qp ~= false then tool.Activated:Connect(function() if codwn ~= true then codwn = true game.ReplicatedStorage.Explosion:FireServer(mouse.Hit.Position) wait(at) codwn = false end end) end
Sorry if this is confusing for you, it's 4 AM.