FireClient arguments glitched?

Hello, so today I am trying to achieve a gui that shows the zombie you killed and how much exp you have gained (very simple), but however, when I pass arguments by using fireclient(), the text in the TextLabel is very glitched. Here’s an example.
image
The server script is very simple, here is it:

local givePointsTo = script.Parent.WhoKilledIt
local zombie = "NORMAL ZOMBIE"
local exp = 5
script.Parent.Humanoid.Died:Connect(function()
	if not givePointsTo.Value.ZombieBio.Zombie.Value == true then
		givePointsTo.Value.ZombieBio.Zombie.Value = true
		givePointsTo.Value.ZombieBio.Zombie.ZombieKills.Value = givePointsTo.Value.ZombieBio.Zombie.ZombieKills.Value + 1
		local leaderstat = givePointsTo.Value:FindFirstChild("leaderstats")
		leaderstat.EXP.Value += exp
		game.ReplicatedStorage.Remotes.ExpGui:FireClient(givePointsTo.Value, zombie, exp) -- FIRE CLIENTS!!!!
	else
		givePointsTo.Value.ZombieBio.Zombie.ZombieKills.Value = givePointsTo.Value.ZombieBio.Zombie.ZombieKills.Value + 1
		local leaderstat = givePointsTo.Value:FindFirstChild("leaderstats")
		leaderstat.EXP.Value += exp
		game.ReplicatedStorage.Remotes.ExpGui:FireClient(givePointsTo.Value, zombie, exp) -- ALSO FIRE CLIENTS!!!
	end
	if script.Parent.Humanoid.Parent.IsGlimmering.Value == true then
		givePointsTo.givePointsTo.Value.ZombieBio.Zombie.ZombieShiny.Value = true
	end
end)

And this is my local script located in the gui.

local frame = script.ZombieKilled

local function cloneTween(zombie, exp)
	local frameClone = frame:Clone()
	frameClone.Text = zombie .. "KILLED! +" .. exp .. " EXP"
	frameClone.Parent = script.Parent
	wait(0.45)
	local info = TweenInfo.new(0.75)
	local tween = game:GetService("TweenService"):Create(frameClone, info,{TextTransparency = 1})
	tween:Play()
	wait(0.75)
	frameClone:Destroy()
end



game.ReplicatedStorage.Remotes.ExpGui.OnClientEvent:Connect(function(zombie, exp)
	spawn(cloneTween, zombie, exp)
end)

I have no idea why this is happening, and when I try to search this up there is nothing, so I am very confused as to why this is even happening in the first place. I think it is the spawn() that glitches it but I am not too sure.

1 Like

Can I see the full explorer for the GivePointsTo variable.

The GivePointsTo variable is a ObjectValue, image

I could be wrong here but you’re passing 3 arguments through ClientFire and only resolving 2 on the OnClientEvent side.

-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

-- Constants
local EXP = 5

-- Died 
script.Parent.Humanoid.Died:Connect(function()
   local givePointsTo = script.Parent.WhoKilledIt
   local player = Players[givePointsTo.Value]
   local leaderstats = player:FindFirstChild("leaderstats")
   local Zombie = script.Parent.Name or "NORMAL ZOMBIE" -- Having the zombie var set to
                                                        -- the script.Parent.Name is better since it is easier to edit
                                                        -- the "or" is there in case the script.Parent.Name is nil

   local function sendClient()
      leaderstats.EXP.Value += EXP
      ReplicatedStorage.Remotes.ExpGui:FireClient(player, Zombie, EXP)
   end

   if not givePointsTo then
      -- Not too sure whats going on here
      -- What is givePointsTo.Value.ZombieBio.Zombie.Value?
      sendClient()
   else
      sendClient()
   end
   
   if script.Parent.IsGlimmering.Value then 
      -- Not sure what's going on here either + you did script.Parent.Humanoid.Parent which is the same as script.Parent
   end
    
end)
-- Local Script

-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

-- Variables
local frame = script.ZombieKilled
local MessageTemplate = "%s KILLED! + %s EXP"

local function cloneTween(zombie, exp)
    local clone = frame:Clone()
    clone.TextLabel.Text = MessageTemplate:format(zombie, exp)
    clone.Parent = script.Parent
    TweenService:Create(clone, TweenInfo.new(0.75), {TextTransparency}):Play()
    -- You can destroy it here, but the wait that goes here is unnecessary since the frame is invisible
    -- clone:Destroy() or you could use Debris Service
end)

ReplicatedStorage.Event:Connect(function(zombie, exp)
   cloneTween(zombie, exp)
end)

Hopefully this helps, I wrote directly so there may be bugs, I haven’t really looked over it. Hopefully it works and next time read some of the code since sometimes there were extra lines that might not need to be there. Good Luck and hope this helps.

1 Like

Thank you very much! This finally works! Even though I had to fix some minor bugs. BTW: the GivePointsTo value is a object value of the player.