Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

my script wont enable things and I dont know why?

This script is supposed to teleport a player to an object when it touches a part, which works, but then it is supposed to enable a gui, which doesnt work.

teleGui = game.StarterGui.Teleport 

game.StarterGui.Teleport.Enabled = false

function touchTele()
local Brick = script.Parent
AnotherBrick = game.Workspace.oiSpawn.SpawnLocation
	 
Brick.Touched:connect(function(part)
   if part.Parent.Humanoid then
          part.Parent:MoveTo(AnotherBrick.Position)
    end
end)
end

function turnOn()
	teleGui.Enabled=true
end

script.Parent.Touched:connect(touchTele)
script.Parent.Touched:connect(turnOn)

1 answer

You have to go into the specific player's PlayerGui to disable Gui's for them, StarterGui just clones any objects into the Player object. I've gone ahead and modified the script to make it possible. You're going to have to manually disable the gui first because I can't reference it before the function.

function touchTele(part) 
local Brick = script.Parent 
AnotherBrick = game.Workspace.oiSpawn.SpawnLocation
if part.Parent.Humanoid then part.Parent:MoveTo(AnotherBrick.Position) 
plr = game.Players:GetPlayerFromCharacter(part.Parent)
teleGui = plr.PlayerGui.Teleport
teleGui.Enabled=true
end
end
script.Parent.Touched:connect(touchTele) 

1 comment

0

Thanks! It worked perfectly.

This discussion is preserved as it was. New answers, comments, and votes are closed.