Hello, there, another question on this tag system.
When attempting to fire a client event from a server script, it keeps returning the error “Unable To Cast Value to Object”. Unsure as to why it is doing this.
The aim of this, is to be able to give players a unique tag in chat when pressing a button on a GUI. So far, the system is able to display tags in chat, the tag is visible to everyone, but it changes the tag for everyone in the server. Attempting to change it only per-player and ran into this issue.
See Code Below:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
-- Reference both events
local tagEvent = ReplicatedStorage.Events:WaitForChild("FireTag")
local localEvent = ReplicatedStorage.Events:WaitForChild("LocalTag")
local function giveTag(player, tagName, tagColor) -- Recieve tag data from client GUI
print(player.Name .. " Now has the tag: " .. tagName)
localEvent:FireClient(tagName, tagColor) -- Fire Client to give tag locally
end
-- Fire Function
tagEvent.OnServerEvent:Connect(giveTag)```
And here is the code in the LocalScript which calls the Client Function:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
-- Get reference to remote event instance
local giveTag = ReplicatedStorage.Events:WaitForChild("LocalTag")
local player = Players.LocalPlayer
local tagFolder = player.PlayerScripts:WaitForChild("ChatTagHandeler")
local tagFold = tagFolder.Tags.Base -- Local storage for player's chat tag info
local function giveTagFunct(tagName, tagColor) -- Pull data from server script to client, change locally
tagFold.Holder:FindFirstChildWhichIsA("StringValue").Name = tagName
tagFold.Holder:FindFirstChildWhichIsA("StringValue").Color.Value = tagColor
end
-- Call Function
giveTag.OnClientEvent:Connect(giveTagFunct)```
