What I’m trying to do is when the explosion hits give you coins, I’m still learning about remote events, I’d like some help correcting what’s wrong.
ServerScript:
local tool = script.Parent
local handle = tool.Handle
local debounce = false
local blastradius = 8
local blastpressure = 20000
local fusetime = 3
local cooldown = 7
local RS = game:GetService("ReplicatedStorage")
tool.Activated:Connect(function()
if not debounce then
debounce = true
local bomb = handle:Clone()
bomb.Parent = workspace
bomb.Position = Vector3.new(handle.Position.X+2,handle.Position.Y,handle.Position.Z)
bomb.CanCollide = true
handle.Transparency = 1
delay(fusetime,function()
local explosion = Instance.new("Explosion", workspace)
explosion.Position = bomb.Position
explosion.BlastRadius = blastradius
explosion.BlastPressure = blastpressure
explosion.Hit:Connect(function(hit)
explosion.DestroyJointRadiusPercent = 0
if hit:GetAttribute("CanDestroy") == false then
print("C")
else
print("Y")
RS.GiveCoins:FireClient()
bomb.PointLight.Enabled = true
bomb.Bombpart:Emit(50)
bomb.Smoke:Emit(50)
wait(0.5)
bomb.PointLight.Enabled = false
end
wait(2.5)
bomb:Destroy()
end)
end)
end
wait(cooldown)
handle.Transparency = 0
debounce = false
end)
Local Script:
local RS = game:GetService("ReplicatedStorage")
local Coins = RS.GiveCoins
Coins.OnClientEvent:Connect(function()
game.Players.LocalPlayer.leaderstats.Coins.Value = game.Players.LocalPlayer.leaderstats.Coins.Value + 1
end)
