i want to get player humanoid in starterGui by player click
local TeleportationDoorEvent = game.ReplicatedStorage:WaitForChild("TeleportationDoorEvent ")
local TpReturn = workspace:WaitForChild("Return")
local debounce = false
script.Parent.MouseButton1Click:Connect(function(click)
if click.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
local plr = game.Players:GetPlayerFromCharacter(click.Parent)
if plr then
TeleportationDoorEvent:FireClient(plr)
wait(0.8)
click.Parent.HumanoidRootPart.CFrame = TpReturn.CFrame
wait(2)
debounce = false
end
end
end
end)
You cannot use a GUI for this. You need to use something known as UserInputService, and a Mouse object, then use that mouse Object to check if theres a humanoid. I recently wrote code for this.
local player = game:GetService("Players").LocalPlayer
local forcelocked = nil
local mouse = player:GetMouse()
local hum = player.Character:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
UserInputService.InputEnded:Connect(function(input,gameprocessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if forcelocked ~= nil then
forcelocked = nil
return
end
pcall(function()
if mouse.Target.Parent:FindFirstChild("Humanoid") then
--print("locked player in")
end
end)
end
end)
Since when? Button.MouseButton1Click() is enough, you don’t need UIS for this. All he needs to do is
local player = game:GetService("Players").LocalPlayer
Button.MouseButton1Click:Connect(function()
Local hum = player.Character:WaitForChild("Humanoid",3)
--your code
end)
Teleport anyone in the server to a specific player in a billboard gui?
A billboard filled with buttons one per player? and when any player clicks any player’s button, they get teleported to that player?
I cant remember right now if billboard has caveats about this, but maybe a surface gui would work too and less resources spent.
You dont need the humanoid, just the HumanoidRootPart CFrame. And you just need to populate the surface gui with all current players in server, connecting an Activated event of each button finding the player in game their CFrame and then move the HRP of the “clicker player” to that target CFrame
You just need to have a local script in the client, updating the current players in server, iterate them, create a button per player, connect the event that does a HRP CFrame change using the coordinates of the target.
Very basic example:
local Players = game:GetService("Players")
local Client = Players.LocalPlayer
local TP_Screen = game.Workspace.SurfaceGUI_Part.SurfaceGui.ScrollingFrame
while true do
TP_Screen:ClearAllChildren()
local newListLayout = Instance.new("UIListLayout")
newListLayout.Parent = TP_Screen
for _, p in pairs(Players:GetPlayers()) do
local btn = Instance.new("TextButton")
btn.Text = p.Name
btn.Size = UDim2.new(1,0,0,100)
btn.TextScaled = true
btn.Parent = TP_Screen
btn.Activated:Connect(function()
Client.Character.HumanoidRootPart.CFrame = p.Character.HumanoidRootPart.CFrame * CFrame.new(0,10,0)
end)
end
wait(5)
end
If you have a part in workspace named SurfaceGUI_Part, with a SurfaceGui as children and a ScrollingFrame as children of SurfaceGui, it will show all players in server as clickable button, of course instead of just change the CFrame of the HRP in client side, you should use a remote for server to handle the CFrame change