Problem with remoteevents

So when a player says a command in the chat it should fire an event to the chatted client but 1 thing doesn’t work…it fires the event but it doesn’t receive it.

Script:

-- !strict

local Player = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Spells = ReplicatedStorage.WitchesAbilities

--Spells Variable
local VolareSpell = Spells.VolareSpell

Player.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(character)
		Player.Chatted:Connect(function(Message : string)
			local Msg = Message:lower()
			if Msg == "volare" then
				VolareSpell:FireClient(Player)
			end
		end)
	end)
end)

Local Script:

-- !strict

local Player = game:GetService("Players").LocalPlayer
local Char = Player.Character
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VolareSpellE = ReplicatedStorage.WitchesAbilities.VolareSpell
local Uis = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
local CD = false
local Distancetospell = 25
local StarterGui = game.StarterGui
local Sound = script:WaitForChild("Sound")

local function OnCoolDown()
	Sound:Play()
	StarterGui:SetCore("SendNotification", {
		Title = "Cooldown",
		Text = "Ability is still on cool down",
		Durating = 5,
	})	
end

VolareSpellE.OnClientEvent:Connect(function()
	print("Received")
	Mouse.Button1Down:Connect(function()
		print("Clicked")
		if not CD then
		local MouseTarget = Mouse.Target
		if not MouseTarget then return end
		if MouseTarget then
			local Target = Mouse.Target:FindFirstChildWhichIsA("Humanoid")
			if not Target then return end
			local PlayerHrp = Player.Character:WaitForChild("HumanoidRootPart")
			if Target ~= nil then
				print("Found a target")
				local TargetHrp = Target.Parent:WaitForChild("HumanoidRootPart")
				local Distance = (PlayerHrp.Position - TargetHrp.Position).Magnitude
				if Distance <= Distancetospell then
					print("Found a perfect distance")
					CD = true
					VolareSpellE:FireServer(Target, Player)
					wait(60)
					CD = false
				else
					print("Distance too long")
				end
				else
				end
			end
		else
			OnCoolDown()
		end
	end)
end)

Basically My main issue is that it doesn’t print received in the local script…why?

2 Likes

Ok so a few things:

  1. Where is the local script?

  2. If you add a print in a if statment that checks the word, does it print anything?

2 Likes
  1. The local script is in starterplay
  2. Yes I added a if statement previously and it did print if the word is written correctly
1 Like