Textbox to player issue

I have been trying to make it so you type a player into a textbox and then tp to them but my issue is that it thinks the person in the textbox is the player inputting it.

I am connecting a localscript to a script and transferring (player, script.parent.text)

I have looked at these:

The first one almost worked but as you saw above it had that problem.

This was my localscript:

local r = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("RSpecial"):WaitForChild("TattooYouGUI")

script.Parent.FocusLost:Connect(function()
	local findplayer = game.Workspace:FindFirstChild(script.Parent.Text)
	local player = game.Players.LocalPlayer
	local character = player.Character
	if not findplayer then return end
	if findplayer:FindFirstChild("Stand") then
		if findplayer.Stand.Value == "Tattoo You" then
			print("ok!")
			r:FireServer(player, script.Parent.Text)
		else
			print("non :rage:")
		end
	end
end)

This was my serverscript

local r = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("RSpecial"):WaitForChild("TattooYouGUI")

r.OnServerEvent:Connect(function(player, Text)
	if player.Name ~= script.Parent.Parent.Name then return end

	local gui = player.PlayerGui.RSpecialsRequiringGUI.TattooYou.Frame
	local findplayer = game.Workspace:FindFirstChild(tostring(Text))
	print(findplayer)
	local character = player.Character
	task.wait(1)
	character:SetPrimaryPartCFrame(findplayer.PrimaryPart.CFrame * CFrame.new(0, 0, -1))
end)

by default, the first variable is always the player who fired the event.

r:FireServer(script.Parent.Text)

so no need to add the player here /\ /\

Sorry for the edits I kinda just skimmed through the post

The problem wasn’t the player1 but it is trying to find player2 in the Textbox which still thinks its the player1 instead of player2

What he’s saying is that, by default, when a localscript runs FireServer() on a RemoteEvent, the first value received on the OnServerEvent is the LocalPlayer instance.

So when you fire

r:FireServer(player, script.Parent.Text)

the server is receiving

(player, player, script.Parent.Text)

meaning that what the server receives is two of the same instance for both “player” and “Text”

Ohhh! That fixes it thank you! I still will be putting the original post as solved though. Thank you for explaining it!

yeah sorry for not explaining it too well lol, glad it worked though

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.