#Teleport wont work or something wont work

116 messages · Page 1 of 1 (latest)

carmine fog
#

is there anything wrong here?

hazy fern
#

@carmine fog I’ll try to explain it as best as I can as I can tell that you’re new to scripting

carmine fog
#

yeah

#

im new

hazy fern
#

So there is quite a lot wrong with the script, starting with the elephant in the room

#

If you want an aspect to change for all players then use a server script

carmine fog
#

ooo

hazy fern
#

The button is inside the UI so we do need a local script to get the input

#

So in your case we need 2 scripts

#

A local and a server script

carmine fog
#

ahhh

hazy fern
#

Starting off with the local script,all we need to do is make it so that if the button is pressed that a remote event fires

#

Then inside the server script we’ve a function that connects to this remote event

#

Because of the nature of remote events we can know which player fired it so we also know which player wants to teleport

#

Then inside the function we just have to then move the player.character

#

Which can be done with :move(), but you’re better off changing Character.PrimaryPart.CFrame

carmine fog
#

oh

#

i see

#

i will be back with another script 👍

hazy fern
carmine fog
#

yes

hazy fern
#

Else you need to reread my messages

carmine fog
#

yeah im rereading it

carmine fog
#

@hazy fern this one right?

solid meadowBOT
#

studio** You are now Level 2! **studio

hazy fern
carmine fog
#

i tried but its wont fire

hazy fern
#

Do you’ve your output open?

carmine fog
#

yeah i do

#

the only related thing to it

hazy fern
#

Hm

#

add a second parameter inside the WaitForChild which is just 10

#

Which means it will only yield for a maximum of 10 seconds

#

@carmine fog you understood that right?

carmine fog
#

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local teleportEvent = ReplicatedStorage:WaitForChild("TeleportEvent", 10)

local screenGui = script.Parent:WaitForChild("ScreenGui", 10)
local button = screenGui:WaitForChild("Obby", 10)

local function onButtonClicked()
teleportEvent:FireServer()
end

button.MouseButton1Click:Connect(onButtonClicked)

#

@hazy fern ?

#

like this or sum

hazy fern
#

Yes that should make the script not stackend

carmine fog
hazy fern
#

Any new errors

carmine fog
#

nope

#

the only related

hazy fern
#

That stack end isn’t related to either of the scripts right?

#

And there are no new errors after pressing the button right?

carmine fog
#

yeah

#

theres none

hazy fern
#

print(Button)

#

Inside the local script anywhere after it gets declared

carmine fog
#

ok

#

like this?

hazy fern
#

Yes

carmine fog
hazy fern
#

Does it take more than 10s for the button to be created?

carmine fog
#

its instantly

#

the button showed up instantly

#

but after a few sec

#

these show up

hazy fern
#

Wait where’s this script located?

carmine fog
#

in the screengui?

hazy fern
#

Show me the explorer please

carmine fog
solid meadowBOT
#

studio** You are now Level 3! **studio

carmine fog
#

Frame 1 is where the button located

hazy fern
#

Well I now see the issue

carmine fog
#

🤯

hazy fern
#

Your script tries to find the screengui inside the screengui

#

Script.parent is the screengui

carmine fog
#

OHHHHH

hazy fern
#

Script.Parent.Screengui = nil

carmine fog
hazy fern
#

No

#

just change line 6 to
local screenGui = script.Parent

carmine fog
#

yeah after fixed

hazy fern
hazy fern
#

Then screengui.obby doesn’t exist

carmine fog
#

uh

hazy fern
#

Wait hang on, obby isn’t inside button right?

carmine fog
#

it inside a frame inside screengui

hazy fern
#

1 or 2?

carmine fog
#

1

hazy fern
#

ScreenGui.Frame1:WaitForChild(“Obby”,10)

carmine fog
#

ok 2 sec

#

seem to be another erro

#

ScreenGui.Frame1:WaitForChild(“Obby”,10) isnt right or sum

#

nv

#

nvm

#

i found out what it meant

hazy fern
#

I’m on phone so there’s probably an issue with my quotes

hazy fern
carmine fog
#

how is that not a valid member

hazy fern
#

Did you move the script?

carmine fog
#

nope

#

the same location inside the screengui

hazy fern
#

First it was a child of Screengui

#

Now it’s a child of playergui

carmine fog
#

hmmmm

#

2 sec

#

lemme see

#

nvm

#

i put it out

#

mb

#

IT WORKED
IT WORKED

#

IT WORKED

#

LETS GOOOOOOOOOOOOOOOOOOOOO

#

TYSM

#

TYSM