ObjectValue not assigning it's value to a Player Object

what are you talking about

the .OnServerEvent:Connect()

is inside the server script not the local script

If it is inside a LocalScript, OnServerEvent can NOT be called.

making the values client-sided tho?

Not exactly sure if this will work in your favor but at least I tried.

local Events = {}
local Data = {}

local BombHasBeenPlanted = function(Player, State)
    if Events[Player.Name] then
        Event:Fire(State)
    end
end

local AddPlayerData = function(Player)
    local Folder = Instance.new("Folder")
    Folder.Name = "Bools"
    Folder.Parent = Player

    local BombInvoke = Instance.new("BindableFunction")
    BombInvoke.Name = "BombPlanted"
    BombInvoke.Parent = Folder

    local Planted = false

    BombInvoke.OnInvoke = function()
        return Planted
    end

    local Event = Instance.new("BindableEvent")
    Events[Player.Name] = Event
    Event.Event:Connect(function(State)
        Data[Player.Name] = State
    end)
end

Remote.OnServerEvent:Connect(function(Player)
    BombHasBeenPlanted(Player, true)
end

Use Player.Bools.BombPlanted:Invoke() to get if the Player has planted the bomb

You can’t make a value client-sided by putting a server-sided function in a LocalScript, you will have some client-server issues, such as not being able to call server events, obviously.

i edited exeplex’s code

function changevalue(player)
    local pbools = player.Bools
    local value = pbools.BombPlanted
    value.Value = player
end

Remote.OnServerEvent:Connect(function(player) -- Changed to lower case
    changeValue(player)

    local bools = Instance.new("Folder", player)
    bools.Name = "Bools"

    local bombplanted = Instance.new("ObjectValue", bools)
    bombplanted.Name = "BombPlanted"

end)

Thanks for taking your time to write that code. I will use it and see if it works how I intended it to.

Fixed some bugers

local Events = {}
local Data = {}

local BombHasBeenPlanted = function(Player, State)
    if Events[Player.Name] then
        Event:Fire(State)
    end
end

local AddPlayerData = function(Player)
    local Folder = Instance.new("Folder")
    Folder.Name = "Bools"
    Folder.Parent = Player

    local BombInvoke = Instance.new("BindableFunction")
    BombInvoke.Name = "BombPlanted"
    BombInvoke.Parent = Folder

    BombInvoke.OnInvoke = function(State)
        if State then
            Data[Player.Name] = State
            return State
        end

        return Data[Player.Name]
    end

    local Event = Instance.new("BindableEvent")
    Events[Player.Name] = Event
    Event.Event:Connect(function(State)
        Data[Player.Name] = State
    end)

    Data[Player.Name] = false
end

Remote.OnServerEvent:Connect(function(Player)
    BombHasBeenPlanted(Player, true)
end)
1 Like

shouldn’t all of the events have an )

Forgot the closure at the remote event yes

that function player added should be called in a player added event

It’s a mockup code not copy and paste, doh