#need help with this script
13 messages · Page 1 of 1 (latest)
so what is the problem,the code didnt work at all or it didnt tp the player?
well,first is local script cannot teleport a player
Second can u try print in the function that u named "Function to handle button click"
so ill know wheres the problem
-- Reference to the TextButton and the part to teleport to
local button = script.Parent -- Assumes the script is a child of the TextButton
local teleportPart = workspace:FindFirstChild("TeleportPart") -- Replace "TeleportPart" with the actual name of your part
-- Function to handle button click
local function onButtonClicked()
print("Button clicked")
-- Check if the player's character exists and the part exists
local character = game.Players.LocalPlayer.Character
if character and teleportPart then
print("Detected some stuffs")
-- Close the Frame
local frame = button.Parent.Parent -- Assumes the script is two levels down from the Frame
if frame then
frame:Destroy()
end
-- Teleport the player to the part
local rootPart = character:FindFirstChild("HumanoidRootPart")
if rootPart then
rootPart.CFrame = CFrame.new(teleportPart.Position + Vector3.new(0, 5, 0)) -- You can adjust the Vector3 offset
end
end
end
-- Connect the function to the button's MouseButton1Click event
button.MouseButton1Click:Connect(onButtonClicked)
Use this and try,and tell me what was printed
god danggg
now ik the problem
bruh something isnt right
u triggered the mouse button correctly
but it didnt send any signal to ur function
wtf💀
have u clicked the button?
while testing?
and have u used my code?