You can write your topic however you want, but you need to answer these questions:
I would like to teleport to spawn a player and put a message (GUI) when they touch a part.
(I’m a huge noob at scripting so I need help to understand)
What is the issue? Include screenshots / videos if possible!
It seems that directly modifying the enabled property of the GUI doesn’t work and I have no idea how to do it.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I think my request is too specific so I haven’t found anything.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Code:
local StarterGUI = game.StarterGui
local Spawn = game.Workspace.Islands.IslandMain.MainIsland.SpawnLocation
local AA = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if AA == true then
AA = false
hit.Parent.HumanoidRootPart.CFrame = Spawn.CFrame*CFrame.new(0, 4, 0)
wait(1)
AA = true
end
end
end)
All the StarterGui does is hold a base copy of what every player’s PlayerGui folder will look like. The PlayerGui under each player is the actual gui that the players use.
You have to reference this gui from the player that touched it.
A large portion of this is pseudo-code by the way, but the comments should be self-explanatory.
local Players = game:GetService("Players")
-- whenever part is touched(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent) -- looks for the player from the character model
if not player then return end -- stop early if no player
-- if debounce then stop early
-- enable debounce
local warnedGui = player.PlayerGui.OceanFallWarned -- get the gui
-- teleport player
wait(1)
warnedGui.Enabled = true
wait(4)
warnedGui.Enabled = false
-- disable debounce
end)
Thanks @goldenstein64 and @cory for helping me! I made a new version of the script:
local Spawn = game.Workspace.Islands.IslandMain.MainIsland.SpawnLocation
local AA = true
local Players = game:GetService(“Players”)
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = Players:GetPlayerFromCharacter(hit.Parent)
local warnedGui = player.PlayerGui.OceanFallWarned
if AA == true then
AA = false
hit.Parent.HumanoidRootPart.CFrame = Spawn.CFrame*CFrame.new(0, 4, 0)
warnedGui.Enabled = true
wait(1)
AA = true
wait(3)
warnedGui.Enabled = false
end
end
end)
I don’t know if it’s the best version but I think a player will have loaded if they touch the part
(there’s indentations in the real script but it doesn’t show here somehow)