Fireclient() cant check the player

- serverscript

local vivyt = true
local limbaranst = game.ReplicatedStorage.posign.glasnotively

script.Parent.Touched:connect(function(hit)
if hit and hit.Parent:FindFirstChild(“Humanoid”) and vivyt then
vivyt = false

  local himu = game.Players:FindFirstChild(hit.Parent.Name)
  himu.Chingua.Value = script.Parent.Name

  local haiu = himu.Chingua.Value
  print("neva "..tostring(himu))

  print("neva "..tostring(haiu))
  limbaranst:FireClient(himu,haiu)
  vivyt = true

end
end)

A Firecilent script worked by touching part.
It fires localscript with himu(player who touched), haiu(himu’s player leaderstat,which worked well)

- localscript

local kamnas = game.ReplicatedStorage.posign.glasnotively

kamnas.OnClientEvent:Connect(function(player,himu,haiu)

print("neva "…tostring(haiu))

print("neva "…player.Chingua.Value)

end)

And here’s localscript to print the information of player who touched part.
.
.
.
testing…

Two values(himu,haiu) worked and fired well in serverscript, but localscript found nothing. pls help

Please consider formatting your code so that it looks proper & more easier to see, you can use 3 backticks (`) to accomplish this :wink:

` ` ` -- Not spaced out
This is a code block!
` ` ` -- End the code here

You have to add a conditional check to make sure that the Player you’re attempting to find, is not equal to nil cause chances are you could be passing through a nil value if there isn’t a valid Player

Also,

There’s no need to pass through the LocalPlayer when using OnClientEvent, as you can easily obtain it in a LocalScript alone

You’re also changing your debounce variable way too early, so it’s frequently triggering every so often which results in instantaneous changes nonstop

-- Server Side
local Part = script.Parent
local vivyt = true
local limbaranst = game.ReplicatedStorage.posign.glasnotively

Part.Touched:Connect(function(hit)
    local Target = hit.Parent

    if not Target then return end

    local Plr = game.Players:GetPlayerFromCharacter(Target)

    if Plr ~= nil and vivyt then
        local Chingua = Plr:WaitForChild("Chingua")

        vivyt = false
        Chingua.Value = Part.Name
        limbaranst:FireClient(Plr, Chingua.Value)

        task.wait(1)

        vivyt = true
    end
end)
-- Local Side

local Plr = game.Players.LocalPlayer
local kamnas = game.ReplicatedStorage.posign.glasnotively

kamnas.OnClientEvent:Connect(function(haiu)
    print("neva "…tostring(haiu))
    print("neva "…Plr.Chingua.Value)
end)
2 Likes

It actually worked! THXXXX
But
– Local Side

local Plr = game.Players.LocalPlayer
local kamnas = game.ReplicatedStorage.posign.glasnotively

kamnas.OnClientEvent:Connect(function(haiu)
    print("neva "…tostring(haiu))
    print("neva "…Player.Chingua.Value) -- HEREEEEEEEE
end)

‘Player’ is not correct value in line 6

image

image
Was the player originally included in fired localscript?

My bad, I forgot to reference a proper variable for it

Try the LocalScript again, I went ahead and re-updated it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.