How to get the player's tool in a server script and a remote event

Hello! I have been making a katana move, and I want the Particle and the Trail activate when the animation get the marker signal. The problem is, I can’t get the tool from the player, how do I get the tool from the remote event’s parameter(player)?

script:

fireAnim.OnServerEvent:Connect(function(plr)

  local Katana = plr:WaitForChild("Backpack"):WaitForChild("Katana") or plr.Character:FindFirstChild("Katana")
  
  print(a) -- used for debugging
  Katana.Blade.SunBreathingPE1.Enabled = true
  Katana.Blade.SunBreathingPE2.Enabled = true
  Katana.Blade.Trail. Enabled = true

end)

Any help is appreciated, thanks!

1 Like

If the player is equipping the tool, that tool is in his characrer.
If not, it is in his backpack.

No need to use WaitForChild here, the remove is always being sent when the player is in-game, cant fire without him being in the game or before the player arrives.

Show us your client side please.

2 Likes

It’s probably not it, but while we’re waiting for the client side, check if you have the same space in your code.

2 Likes

Sorry for the late reply, here’s the whole script:
Server script (server script storage):

local storage = game:WaitForChild("ReplicatedStorage")
local fireAnim = storage:WaitForChild("FireAnim")
local debris = game:GetService("Debris")
local cd = false

local moveAnim = Instance.new("Animation")
moveAnim.AnimationId = "rbxassetid://9584541008"

fireAnim.OnServerEvent:Connect(function(plr)
	if cd == false then
		cd = true
		local char = workspace:WaitForChild(plr.Name)
		local HRP = char:WaitForChild("HumanoidRootPart")
		local humanoid = char:WaitForChild("Humanoid")
		local moveAnimTrack = humanoid:LoadAnimation(moveAnim)
		moveAnimTrack:Play()
		humanoid.WalkSpeed = 0
		humanoid.JumpHeight = 0
		humanoid.AutoRotate = false
		moveAnimTrack:GetMarkerReachedSignal("PE Enable"):Wait(0)
		local Katana = plr:WaitForChild("Backpack"):WaitForChild("Katana") or plr.Character:FindFirstChild("Katana")
		print("a")
		Katana.Blade.SunBreathingPE1.Enabled = true
		Katana.Blade.SunBreathingPE2.Enabled = true
		Katana.Blade.Trail. Enabled = true
		moveAnimTrack:GetMarkerReachedSignal("Hitbox"):Wait(0)
		local hitBox = storage:WaitForChild("FireDanceHitBox"):Clone()
		hitBox.CFrame = HRP.CFrame * CFrame.new(0,0,-3.5) * CFrame.new(HRP.CFrame.LookVector)
		hitBox.Parent = workspace
		hitBox.Touched:Connect(function(hit)
			if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") then
				local hitHumanoid = hit.Parent:WaitForChild("Humanoid")
				hitHumanoid.Health -= 10
				hitBox:Destroy() 
			end
		end)
		debris:AddItem(hitBox, .1)
		moveAnimTrack.Stopped:Wait(.3)
		humanoid.WalkSpeed = 16
		humanoid.JumpHeight = 7.2
		humanoid.AutoRotate = true
		wait(2)
		cd = false
	end
end)

local script:

local storage = game:WaitForChild("ReplicatedStorage")

local fireAnim = storage:WaitForChild("FireAnim")

local UIS = game:GetService("UserInputService")

local katana = script.Parent

local equipped = false

katana.Equipped:Connect(function()

equipped = true

end)

katana.Unequipped:Connect(function()

equipped = false

end)

UIS.InputBegan:Connect(function(input, GPE)

if input.KeyCode == Enum.KeyCode.E and GPE == false and equipped == true then

fireAnim:FireServer()

end

end)

Thanks!

You are right, I named both the tool and the model “Katana” and cofused myself, silly me! Thanks!

2 Likes

It worked! Thank you!! I will watch out for the careless mistakes! :smile: Thanks!

2 Likes