Tp Request Issue

Chat

elseif cmdname == Prefix .. "tpreq" then
			
			local PlrToTpReq = args[2]
			
			for _, currentplr in pairs(game.Players:GetPlayers()) do
				
				if string.lower(string.sub(currentplr.Name,1,PlrToTpReq:len())) == PlrToTpReq then
					
					game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").ActivateTpReqPrompt:FireClient(currentplr,currentplr)
					
				end
				
			end
			
		end

UI Prompt

local ActivateTpReqPrompt = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").ActivateTpReqPrompt

local TpReqUI = script.Parent

local Requester

ActivateTpReqPrompt.OnClientEvent:Connect(function(TpRequester)
	
	Requester = TpRequester
	
	TpReqUI.PlrRequesting.Text = "Tp Req From: " .. TpRequester.DisplayName
	
	TpReqUI.Enabled = true
	
	task.wait(15)
	
	if TpReqUI.Enabled == true then
		
		TpReqUI.Enabled = false
		
	end
	
end)

local Decline = TpReqUI.Decline

local Accept = TpReqUI.Accept

local TpReqPromptVerdict = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").TpReqPromptVerdict

local CS = game:GetService("CollectionService")

for _, Button in pairs(CS:GetTagged("TpReqVerdictButton")) do
	
	Button.MouseButton1Click:Connect(function()
		
		TpReqPromptVerdict:FireServer(Button.Name,Requester)
		
		TpReqUI.Enabled = false
		
	end)
	
end

Server (Prints both same name)

local TpReqPromptVerdict = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").TpReqPromptVerdict

TpReqPromptVerdict.OnServerEvent:Connect(function(plr, Verdict, PlrToTpTo)
	
	print("Requester: " .. plr.Name)
	
	print("Target: " .. PlrToTpTo.Name)
	
	if Verdict == "Accept" then
		
		local Char = plr.Character
		
		if Char and PlrToTpTo then
			
			PlrToTpTo.Character:Pivot(CFrame.new(Char.HumanoidRootPart.Position))
			
		end
		
	end
	
end)

Issue:
image

Use PivotTo instead of Pivot

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