The game I am currently working on uses multiple places, the main place is the title screen place. Basically, you hit play and you join the actual fighting game. The problem with this is that you can’t join any specific players game, including friends. To combat this, we put a “Join Username” GUI. You type someones name in the text box and hit join, and if they are in the game, then you will teleport to the server that they’re in.
Now the problem is, I keep getting this error that no coder I know understands. “unable to cast string on int64”. have no idea how it makes sense on the line it errored at. It is erroring at line 116.
--Join Username
joinFriend = container:WaitForChild("JoinFriend")
joinButton = joinFriend:WaitForChild("JoinButton")
usernameInput = joinFriend:WaitForChild("UsernameInput")
joinUsername = game:GetService("ReplicatedStorage"):WaitForChild("JoinUsername")
joinButton.MouseButton1Click:Connect(function()
local name = usernameInput.Text --Target player's name.
--print(name,joinUsername)
local value = joinUsername:InvokeServer(name)
if value == false then
spawn(function()
usernameInput.Text = "User is not in-game."
wait(3)
if usernameInput.Text == "User is not in-game." then --Make sure they didn't edit while waiting
usernameInput.Text = "Username"
end
end)
end
end)
Line 116 is
local value = joinUsername:InvokeServer(name)
I don’t understand how a string is being cast on an integer.
Here is the server script where he RemoteFunction is set up.
game:GetService("ReplicatedStorage"):WaitForChild("JoinUsername").OnServerInvoke = function(player, name)
local playerid = game:GetService("Players"):GetUserIdFromNameAsync(name)
local wasFound, placeId, jobId
local success, errorMessage = pcall(function()
wasFound, placeId, jobId = game:GetService("TeleportService"):GetPlayerPlaceInstanceAsync(playerid) --Return the players game instance if they are in-game.
end)
if success then
game:GetService("TeleportService"):TeleportToPlaceInstance(placeId,jobId,player)
return true
else
print(errorMessage)
return false
end
end
Thank you for the help.