#Help with remotes

1 messages · Page 1 of 1 (latest)

wheat locust
#

just to lyk, I'm very new to scripting. I have the following script in workspace
"local Players = game:GetService("Players")
local Remote = game:GetService("ReplicatedStorage").UITrigger1
local ws = game:GetService("Workspace")
local Box = ws.Area1

local SpawnPart = Box.Spawn

local TeleportA = Box.Folder.PartA

TeleportA.CanTouch = true

TeleportA.Touched:Connect(function(hit)
local WhoTouched = hit.Parent:FindFirstChild("HumanoidRootPart")
if WhoTouched then
WhoTouched.CFrame = SpawnPart.CFrame
TeleportA.CanTouch = false
TeleportB.CanTouch = false
TeleportC.CanTouch = false
TeleportD.CanTouch = false
Remote:FireClient()
end
end)
"
Basically when the player touches a part I need certain GUI to become visible.

Heres the LocalScript "local Remote = game:GetService("ReplicatedStorage").UITrigger1
local UI = game:GetService("StarterGui").Teleporters.SG.Frame

Remote.OnClientEvent:Connect(function()
UI.Visible = true
end)
"
Why is this not working?

twilit fox
#

Your LocalScript is looking in the wrong place for the GUI

chilly hazelBOT
#

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

wheat locust
twilit fox
# wheat locust Where should it be?

ur GUI should be inside StarterGUI and the local script inside StarterPlayerScripts but you’re also using
local UI = game:GetService("StarterGui").Teleporters.SG.Frame
which won’t work because that’s just the template and not what the player sees

#

try replacing that line with

local player = game.Players.LocalPlayer
local UI = player:WaitForChild("PlayerGui"):WaitForChild("Teleporters").SG.Frame

wheat locust
twilit fox
#

Remote:FireClient() is causing the error because it needs a player as its first argument

#

you need to change it to

#

Remote:FireClient(player)

#

and you should add

#

local player = Players:GetPlayerFromCharacter(character)

#

above that

#

that line will figure out which player touched the teleporter

wheat locust
twilit fox
#

You don’t have to put anything in because character is already the name you gave to the body that touched the part

wheat locust
chilly hazelBOT
#

studio** You are now Level 7! **studio

wheat locust
#

I assume scripts don't have acess to "characters"

twilit fox
#

that probably means you forgot to define it first

#

which means u need to add
local character = hit.Parent

before the line
local player = Players:GetPlayerFromCharacter(character)

#

it’ll tell the script what “character” is

wheat locust