I am currently working on a way to pass a number value from server to client, but I get this error whenever I start testing it.
![]()
I am using this a simple block breaking system that I am working on just for fun and to sharpen my skills, so the code is very messy.
Code:
local event = game:GetService("ReplicatedStorage").BlockHpEvent
for i,v in ipairs(workspace:GetDescendants()) do
if v:IsA("Part") then
for i,v in ipairs(v:GetDescendants()) do
if v:IsA("NumberValue") then
if v.Name == "Strength" then
v.Parent.ClickDetector.MouseClick:Connect(function()
v.Value -= 2
if v.Value < 1 then
v.Parent.Parent = game:GetService("ReplicatedStorage").DeletedParts
end
end)
v.Parent.ClickDetector.MouseHoverEnter:Connect(function()
local BlockHp = v.Value
event:FireClient(BlockHp)
local selBox = Instance.new("SelectionBox")
local color = v.Parent.Color
local r, g, b = 0,0,0
r = 255 - (color.R*255)
g = 255 - (color.G*255)
b = 255 - (color.B*255)
selBox.Color3 = Color3.fromRGB(r,g,b)
selBox.Adornee = v.Parent
selBox.Name = "selBox"
selBox.Parent = v.Parent
end)
v.Parent.ClickDetector.MouseHoverLeave:Connect(function()
for i,v in ipairs(v.Parent:GetDescendants()) do
if v:IsA("SelectionBox") then
if v.Name == "selBox" then
v:Destroy()
end
end
end
end)
end
end
end
end
end
The part that is having the error is this:
local BlockHp = v.Value
event:FireClient(BlockHp)
I have never passed information from server to client, I have done client to server, but they should be the same so I don’t know why this is happening.
Oh yeah, here is the client script, if you catch any error please say.
local event = game:GetService("ReplicatedStorage").BlockHpEvent
local plr = game.Players.LocalPlayer
game.ReplicatedStorage.BlockHpEvent.OnClientEvent:Connect(function(plr,BlockHp)
script.Parent.Visible = true
while wait() do
script.Parent.BlockHpLabel.Text = BlockHp
if BlockHp < 1 then
script.Parent.Visible = false
end
end
end)
Any help would be appreciated!
