I am making a tool that creates a bomb across all clients.
When the RemoteEvent is fired, it says the part is being created but it is not appearing in Workspace.
This is the LocalScript in the Tool.
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Cooldown = 10
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Check = true
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreateBomb = ReplicatedStorage:WaitForChild("CreateBomb")
Tool.Activated:Connect(function()
print(Check)
local Torso = Character:WaitForChild("LowerTorso")
local TorsoPosition = Torso.Position
if Check == true then
Check = false
print("Spawned!")
CreateBomb:FireServer(TorsoPosition)
wait(Cooldown)
Check = true
And this is the ServerScript.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreateBomb = ReplicatedStorage:WaitForChild("CreateBomb")
local TweenService = game:GetService("TweenService")
local CanPlaySound = true
CreateBomb.OnServerEvent:Connect(function(player, TorsoPosition)
print(player.Parent)
local Character = player.Character or player.CharacterAdded:Wait()
print(Character)
local Object = Instance.new("Part")
Object.Parent = game.Workspace:WaitForChild("MapHolder")
Object.Shape = Enum.PartType.Ball
Object.Size = Vector3.new(16, 16, 16)
Object.Rotation = Vector3.new(math.random(0, 360), math.random(0, 20), math.random(0, 20))
local BombMesh = game.ReplicatedStorage:WaitForChild("BombMesh"):Clone()
BombMesh.Parent = Object
local TickingSound = game.ReplicatedStorage.TickingSound:Clone()
TickingSound.Parent = Object
print(TickingSound.Parent)
TickingSound:Play()
local PhysProperties = PhysicalProperties.new(10, 0.3, 1, 1, 1)
Object.CustomPhysicalProperties = PhysProperties
Object.Position = TorsoPosition - Vector3.new(0, 25, 0)
Object.Velocity = Vector3.new (math.random(-15, 15), -100, math.random(-15, 15))
print(Object.Velocity)
Object.Touched:Connect(function(hit)
local Explosion = Instance.new("Explosion")
Explosion.BlastRadius = 20
Explosion.Position = Object.Position
Explosion.Parent = Object
if CanPlaySound == true then
CanPlaySound = false
local ExplosionSound = game.ReplicatedStorage.ExplosionSound:Clone()
ExplosionSound.Parent = Object
ExplosionSound:Play()
end
local TweenInfo = TweenInfo.new(1.2)
local Goal = {}
Goal.Transparency = 1
local Tween = TweenService:Create(Object, TweenInfo, Goal):Play()
wait(1.2)
CanPlaySound = true
end)
Object:Destroy()
end)