Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

my script wont enable things and I dont know why?

Asked by 6 years ago
Edited by BlueTaslem 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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) 
0
Thanks! It worked perfectly. djunicorn205 -5 — 6y
Ad

Answer this question