OK so the issue is that the Event is inside a function that it is trying to call so it never runs the function
replace this
sendPrimaryItemInfo.OnServerEvent:Connect(onSendPrimaryItemInfo)
end
end)
-- With
end
sendPrimaryItemInfo.OnServerEvent:Connect(onSendPrimaryItemInfo)
end)
When you do OnServerEvent the arguments are always (PLAYER,ARGUMENT) So in your case you would need to do onPrimaryEquippedItem(player,PrimaryEquippedItem)
open.MouseButton1Click:Connect(function()
print("Click")
local remotes = game.ReplicatedStorage:WaitForChild("Remotes")
local sendPrimaryItemInfo = remotes:WaitForChild("SendPrimaryItemInfo")
function onPrimaryEquippedItem(PrimaryEquippedItem)
print("got it")
local primaryEquippedItem = PrimaryEquippedItem
for _, v in pairs(workspace.ToolModels:GetChildren()) do
if not v:IsA("Frame") then
v:Destroy()
end
local handle = game.StarterGui:WaitForChild("Folder"):FindFirstChild(primaryEquippedItem.."Handle"):Clone()
handle.Parent = workspace.ToolModels
print("cloned")
handle.Script.Disabled = false
end
sendPrimaryItemInfo.OnServerEvent:Connect(onPrimaryEquipped(player, primaryEquippedItem))
end
end)
Sorry but from the looks of it you didn’t do what I said
open.MouseButton1Click:Connect(function()
print("Click")
local remotes = game.ReplicatedStorage:WaitForChild("Remotes")
local sendPrimaryItemInfo = remotes:WaitForChild("SendPrimaryItemInfo")
wait(.4)
function onSendPrimaryItemInfo(PrimaryEquippedItem)
print("got it")
local primaryEquippedItem = PrimaryEquippedItem
for _, v in pairs(workspace.ToolModels:GetChildren()) do
if not v:IsA("Frame") then
v:Destroy()
end
end
local handle = game.StarterGui:WaitForChild("Folder"):FindFirstChild(primaryEquippedItem.Value.."Handle"):Clone()
handle.Parent = workspace.ToolModels
print("cloned")
handle.Script.Disabled = false
end
sendPrimaryItemInfo.OnServerEvent:Connect(onSendPrimaryItemInfo)
-- You had a random end right here
end)
as @rottendogDkR said hover over the orange underline and tell us what it says
In the script fire to the client and inside of the client fire the event and technically you dont need an event since your detecting the click on server