ObjectValue value problem

Hi! I have a little issue here. I am using an ObjectValue(through a local script) to determine what template(a frame) is selected.

When I click a button and send the ObjectValue.Value through remote event, in serverside, it says that the Value is nil. Still, I’m using a remote event so even if the objectvalue.Value is locally set, it shouldn’t be nil in server. Hope you can help me!

May I see the script(s) and your Explorer window / Output window?

The “Dog” is the Value of the objectvalue locally, “Fired” is to make sure and “nil” is the value of the objectvalue serverside.
ObjectValueProblem.

The PetTemplate is the value of the ObjectValue and you can see that Equipped is here.
ObjectValueProblem.

– Local Script

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Parent.SelectedTemplate.Value ~= nil and script.Parent.Parent.PetView.PetName.Text ~= nil then
		print(script.Parent.Parent.SelectedTemplate.Value)
		Remote:FireServer(script.Parent.Parent.PetView.PetName.Text, script.Parent.Parent.SelectedTemplate.Value)
	end
end)

In the server, I have : local function EquipPet(player, petName, template)

Server is like this?

remote.OnServerEvent:Connect(function(player, petName, template)
    -- rest of code
end)

Yes, it’s like that in the server script.

try using

tostring(template)

in the server. I don’t know if this would help but in some cases for me it helps.

I need the Instance, not a string.

I tried to do all the things similiar like you did, and it works for me

Without doing " tostring()"

My templates are created locally within a local script in-game.

This is my last idea, try doing something like this:

Client:

Remote:FireServer(script.Parent.Parent.PetView.PetName.Text, script.Parent.Parent.SelectedTemplate) -- didn't send the value only the object

Server:

remote.OnServerEvent:Connect(function(player, petName, template)
   print(template.Value)
end)

Hmm… ok so if everything looks like this:

-- LocalScript
script.Parent.MouseButton1Click:Connect(function()
    local value = script.Parent.Parent.SelectedTemplate.Value
    local name = script.Parent.Parent.PetView.PetName.Text
    if value and name ~= "" then
        remote:FireServer(value, name)
    end
end)

-- ServerScript
remote.OnServerEvent:Connect(function(player, template, petName)
    -- rest of code
end)

It should work perfectly.

2 Likes

That’s what I have but it doesn’t work.

1 Like

Actually, I might have an idea. I wanna use a remote event to update SelectedTemplate.Value every time the one locally is updated.

Not sure what’s up. Can you take screen shots of your button LocalScript, your server Script, your Output window, and your Explorer window? If I can see all of these as screen shots, I can try to pinpoint the problem.

I know the problem is that local changes doesn’t save on the serverside but I don’t know how to fix that.

ObjectValue:GetPropertyChangedSignal("Value"):Connect(function()
    if ObjectValue.Value ~= nil then
        remote:FireServer(ObjectValue.Value)
    end
end

When the value is changed, it sends the value over to the server. Is this what you’re talking about?

Lemme explain.

You have pet templates(frames) displayed in a gui. Then, each time you click on of those, the ObjectValue.Value becomes that clicked template and there’s an info gui showing up the pets stats and an “Equip” button. Then, in another button(equip), when you click it, it gets the value of the ObjectValue and sends it into the server.

The question is : Can server get local Instances through a remote event? Even if it’s nowhere in serverside?

This is the best solution I can come up with at the moment. The only thing I can think of that is preventing this from working is that something is not being referenced correctly (wrong value/name). I’ll get back to you if I can think of another solution.