#FireClient a Part?

1 messages · Page 1 of 1 (latest)

frigid bronze
#

Hey, i was wondering, if anyone know, why im not able to FireClient a Part to User?

Let's say, i have this Script on Server Side:

local function setupClick(part, player)
    local clickDector = Instance.new("ClickDetector", part)
    
    clickDector.MouseClick:Connect(function(clickingPlayer)
        if clickingPlayer ~= player then return end
        
        local breakPower = part:GetAttribute("BreakPower") - 1
        part:SetAttribute("BreakPower", breakPower)
        if breakPower <= 0 then
            PlayerSystem.AddItem(clickingPlayer, part.Name, 1)
            
            local blockName, blockData = getRandomBlock()
            
            local newBlockTemplate = RS.Models.Minecraft:FindFirstChild(blockName)
            local newBlock = newBlockTemplate:Clone()
            newBlock.Parent = workspace.PlayerPlot[player.Name]
            newBlock.CFrame = part.CFrame
            newBlock:SetAttribute("BreakPower", blockData.BreakPower)
            
            if blockData.BreakPower > 1 then
                local updateUI = RS.RemoteEvent:WaitForChild("ShowBlockUI")
                updateUI:FireClient(player, newBlock) -- <== Result is "nil"
            end
            
            part:Destroy()
            setupClick(newBlock, player)
            
        end
    end)
end

For client i have currently just debug stuffs, such print(part)

event.OnClientEvent:Connect(function(part)
    print(part)
end)

If i change the newBlock to newBlock.Name, it seems to be output the name of the Part. hmmGe

I kinda found alternativ way, but i feel its a bit unsafe.

event.OnClientEvent:Connect(function(partName)
    local block = workspace.PlayerPlot[player.Name]:FindFirstChild(partName)
    print(block)
    attach(block, block:GetAttribute("BreakPower"))
end)

I just wanted to know, if someone have experience in this area, and maybe, know a better way?

Thanks in advance.

tranquil warren