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).
This is the test GUI:
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)
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.
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?