Tool not activating when clicked

Hello, I am trying to create a game where one player is given a tool and the others have to survive from said player.
I am having an issue with the tool. It works as intended when placed into the StarterPack, but when I clone it into a player’s backpack from ServerStorage the tool does not activate.

The tool creates a giant bomb that explodes when it touches another object.
Here’s the code:

local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Cooldown = 10
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local Check = true
local TweenService = game:GetService("TweenService")
local CanPlaySound = true

Tool.Activated:Connect(function()
	print(Check)
	local Torso = Character:WaitForChild("LowerTorso")
	if Check == true then
		Check = false
		local Object = Instance.new("Part")
		Object.Parent = game.Workspace
		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
		TickingSound:Play()
		local PhysProperties = PhysicalProperties.new(10, 0.3, 1, 1, 1)
		Object.CustomPhysicalProperties = PhysProperties
		Object.Position = Torso.Position - 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
			Object:Destroy()
		end) 
		wait(Cooldown)
		Check = true
	end
end)

Instead of doing

local Character = Player.CharacterAdded:Wait()

do

local Character = Player.Character

The best way for that is:

local Character = Player.Character or Player.CharacterAdded:Wait()
1 Like

He is using a server script so getting the player is a bit weird so i’m telling him to use a local script and a remote event

This fixed the problem, but now I’m having another. The bombs created from the tool’s activation are only client-sided.

Fire a remote event that creates the bomb!

1 Like