I am attempting to make a shop UI that when clicked creates a clone of the hat and then clones that hat to the player. I can clone te hat and everything is fine up until I call the equipEvent remote event and then I get the error.
"19:37:39.683 - Trying to call method on object of type: RemoteEvent with incorrect arguments."
Here is the code of the main UI
local player = game:GetService("Players").LocalPlayer
local equipEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").EquipHat
local BaseballCap = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.BaseballCap
local BaseballCapCost = script.Parent.BaseballCap.ItemCost
local BaseballCapButton = script.Parent.BaseballCap.BuyButton
local BasicFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.BasicFedora
local BasicFedoraCost = script.Parent.BasicFedora.ItemCost
local BasicFedoraButton = script.Parent.BasicFedora.BuyButton
local BlackStripedFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.BlackStripedFedora
local BlackStripedFedoraCost = script.Parent.BlackStripedFedora.ItemCost
local BlackStripedFedoraButton = script.Parent.BlackStripedFedora.BuyButton
local FancyFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.FancyFedora
local FancyFedoraCost = script.Parent.FancyFedora.ItemCost
local FancyFedoraButton = script.Parent.FancyFedora.BuyButton
local GreenFedora = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats.GreenFedora
local GreenFedoraCost = script.Parent.GreenFedora.ItemCost
local GreenFedoraButton = script.Parent.GreenFedora.BuyButton
local humanoid = player.Character:WaitForChild("Humanoid")
local debouce = false
local equipped = false
local accessories = {}
--insert default accessory table
for i,v in pairs(humanoid:GetAccessories()) do
table.insert(accessories,v:Clone())
end
function ResetItems()
humanoid:RemoveAccessories()
for i,v in pairs(accessories) do
--equipEvent(v)
end
end
function EquipHat(hat)
local hatClone = hat:Clone()
hatClone.Name = hat.Name.."Clone"
hatClone.Parent = game:GetService("ReplicatedStorage"):WaitForChild("Items").Hats
equipEvent(hatClone)
end
function SetButtonText()
if player:WaitForChild("leaderstats").Items.OwnsBaseballCap.Value == true then
BaseballCapButton.Text = "Equip Hat"
end
end
SetButtonText()
BaseballCapButton.MouseButton1Click:Connect(function()
if debouce == false then
debouce = true
if player:WaitForChild("leaderstats").Items.OwnsBaseballCap.Value == true then
print("He owns the cap")
if equipped == false then
equipped = true
print("equipped item")
humanoid:RemoveAccessories()
EquipHat(BaseballCap)
BaseballCapButton.Text = "Unequip"
else
equipped = false
ResetItems()
print("unequipped item")
BaseballCapButton.Text = "Equip"
end
else
print("player does not own baseball cap")
end
wait(.5)
debouce = false
end
end)
here is the code of my remote event
game:GetService("ReplicatedStorage").RemoteEvents.EquipHat.OnServerEvent:Connect(function(player,hat)
player.Character.Humanoid:AddAccessory(hat)
end)

1 comment
Use
RemoteEvent:FireServer(arguments)to call the events