Unable to assign property Value. Object expected, got number Error

Hi! :slight_smile:
Edit: Everything that I writed on this post was wrong. I updated it to the correct information.
Edit2: I already found the problem that was causing the error as mentioned in Message #3!

Basically this is what I’m trying to do:
I’m integrating these scripts into a Teletransportation Model created by callmehbob (when a player touches a part, he is teleported to another part) that a builder of my game used for a portal.

So I will try to explain in the best way how the scripts work (there is probably a simpler way to make this work, but It’s only been around 3 days since I started trying to learn scripting again but this time seriously so it doesn’t matter).

GUI
This is the test GUI:
a

The objective of the first button is to teleport the player to the Lobby.

The objective of the second button is to teleport the player to the current stage of the obby (by getting the leaderstats value).

Ignore the third button. If I can make the second work I can make this one work. Basically the player imputs the stage number and if the number is smaller than the stage leaderstats value of the player it then teleports them to the imputed stage. It can only make the player go backwards in case the player wants to play a especific stage again or if the player wants to meet with a friend, for example…

ServerScriptService Main Script

Destination is a ObjectValue and it’s Value refers to a Stage Checkpoint in workspace. That ObjectValue is inside every button along with the LocalScript.

This is the Script that is in ServerScriptService that Fires the TP Model Remote Event and/or changes the Destination Value on the Server to the current Stage Leaderstats Value from the player that pressed the button.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local animationEvent = ReplicatedStorage:FindFirstChild("DoTeleport")
local guiEvent = ReplicatedStorage:FindFirstChild("DoGuiTeleport")
local playerStats = ReplicatedStorage:FindFirstChild("Stats")

guiEvent.OnServerEvent:Connect(function(player, path)
	animationEvent:FireClient(player, path.Value)
end)

playerStats.OnServerEvent:Connect(function(player, path)
	local stage = player.leaderstats.Stage.Value
	path.Value = stage --Here is where I get the error! Read Message #3!
end)

First Button
This is the LocalScript inside the first button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:FindFirstChild("DoGuiTeleport")
local path = game.Players.LocalPlayer.PlayerGui.Teleport.Frame.Lobby.Info.Destination

script.Parent.MouseButton1Down:Connect(function()
	event:FireServer(path)
	script.Parent.Parent.Parent.Visible = false
end)

After this script fires the event everything works. The player is teleported to Stage 0 (the lobby). It gets the Destination.Value from the ServerScriptService Script so the player can’t change where to teleport.

Second Button
This is the LocalScript inside the second button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local playerStats = ReplicatedStorage:FindFirstChild("Stats")
local event = ReplicatedStorage:FindFirstChild("DoGuiTeleport")
local path = game.Players.LocalPlayer.PlayerGui.Teleport.Frame.Current.Info.Destination

script.Parent.MouseButton1Down:Connect(function()
	playerStats:FireServer(path)
	wait(0.5)
	event:FireServer(path)
	script.Parent.Parent.Parent.Visible = false
end)

When the player presses the button the LocalScript fires a Remote Event to the ServerScriptService Script. The Script then gets the leaderstats.Stage.Value of the player (I think it’s from the Server, but I’m not sure). Then my objective is for the Script to change the Destination.Value of the player to the player’s leaderstats.Stage.Value on the server, so the player can’t change to where he is teleporting (for example to the final of the obby).

This is where the error occurs in line 12 of the ServerScriptService Script:

Unable to assign property Value. Object expected, got number

Can someone help me fix this error?
Thanks!

GetFullName is usually intended just for debugging. It gives you a dot-separated string, like "game.Players.ZuperManoz.PlayerGui.ScreenGui.Button"

You can’t directly use a string like that usefully.

However, you can just send instances across the network, as long as both the server and client have that instance. Which, in this case, is not true—only the client has access to their own PlayerGui and LocalScripts.

Where is Destination supposed to be? How is it set in the first place?

At a high level how do you envision this system working? Does the player choose a location from a list of buttons and then the server teleports them or something?

4 Likes

I edited the post, everything I wrote there was wrong and I was using older versions of the script.
When I finished writing everything again, I noticed what was causing the error:

I forgot to path the folder in workspace with all the Checkpoints in it. Now this line is written like this:

path.Value = workspace.Checkpoints:FindFirstChild(stage)

Even so, could you read the post again to check if everything is correct and if the values are being read or changed in the ServerScript and not Locally?

1 Like

You mean destination.Value or destination.Text?

I mean Destination.Value that can be seen in the ServerScriptService Script here:

Or here: