Remote Event not working

LOCAL SCRIPT

local Equip = script.Parent
local InvHandler = game.Players.LocalPlayer.PlayerGui.InventoryHandler 
local UpperInv = InvHandler.UpperInv
local MaxPetLimit = UpperInv.MaxPetLimit
local PetLimitText = MaxPetLimit.PetLimitText
local PetPreview = UpperInv.PetPreview
local PetPreviewFrame = PetPreview.PetPreviewFrame
local Im = PetPreviewFrame.PetPreviewImage
-- We just defined all the UI elements 



local ReplicatedStorage = game:GetService("ReplicatedStorage")

Equip.MouseButton1Click:Connect(function()
	
		if Im.Image =="rbxassetid://7620353586" then-- checking if the pet is a cat 
		
	
		local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")-- waiting for remote event
		EquipPet:FireServer() -- fire the event
	print("WWWWWWWWWWWWWWWWWWWWWWWWWW")
	
		end

	end)
	
	

Via Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")
local char = game.Workspace:WaitForChild("Character")
local humRoot = char:FindFirstChild("HumanoidRootPart")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BasicEggPetFolder = ReplicatedStorage.BasicEggPetFolder

local Cat = BasicEggPetFolder.Cat
local Dog = BasicEggPetFolder.Dog
local Mouse = BasicEggPetFolder.Mouse
local Dragon = BasicEggPetFolder.Dragon
local GrassyCat = BasicEggPetFolder.GrassyCat
local TeaMonster = BasicEggPetFolder.TeaMonster


EquipPet.OnServerEvent:Connect(function(player, Clo1)
local Cat = BasicEggPetFolder.Cat
local Clo1 = Cat:Clone()
local StatsValue = Instance.new("StringValue")

StatsValue.Parent = Clo1

StatsValue.Value = "Equipped"

Clo1.Parent = char

--Clo1:SetPrimaryPartCFrame(humRoot.CFrame)

print("Worked")

end)

Whenever the client clicks the EquipPet on the inventory the pet will clone to his char and make it so everybody can see the pet, but I am having issues with enacting that.
So there is no error in the output the WWWWWWWWWWWWWWW print ran perfectly but the Worked print did not run. I think the remote event did not run because when I went on the server perspective I saw no cloned cat in the char.

You retrieve Character outside the remote function? When you test is your character within Workspcae named "Character"

What you should do

EquipPet.OnServerEvent:Connect(function(player, Clo1)
local Character = player.Character or  player.CharacterAdded:Wait()
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Cat = BasicEggPetFolder.Cat
local Clo1 = Cat:Clone()
local StatsValue = Instance.new("StringValue")
StatsValue.Parent = Clo1
StatsValue.Value = "Equipped"
Clo1.Parent = Character
print("Worked")
end)

Iā€™d also remove the Char and HumRoot you have outside the event handler

1 Like