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

How to not show custom play button when player respawn?

Asked by
L30N_C 27
4 years ago
Edited 4 years ago

I'm very new to Roblox studio and scripting and I'm still learning, so please bare with me, I've only made one game and I'm working on my second. In this new game I have made a custom "Play" button and a title screen with a fixed camera. When the player clicks "Play" the camera changes to the player amd the play button is hidden.

However, every time the player dies, the camera goes back to the title screen and the play button and after clicking "play", the camera returns to the place of death with the camera stuck, instead of following the player.

I realize I need to change the play button/title screen so it only shows to the player when entering the game and not when respawning, do you think that would also fix the problem with the camera being fixed and not following the player after respawn? Any suggestions? (I'm only 13 and English is not my first language so sorry if I'm not making sense)

Below is the "Play" button script:

local Camera = game.Workspace.CurrentCamera
local Sound = script.Parent.Parent.ButtonSound
local Sound2 = script.Parent.Parent.ButtonComfirm

-- Main --

script.Parent.MouseButton1Click:Connect(function()
    Camera.CameraType = "Custom"
    script.Parent.Visible = false
end)

script.Parent.MouseEnter:Connect(function()
    Sound:Play()
end)

script.Parent.MouseLeave:Connect(function()
    Sound.Playing = false
end)

script.Parent.MouseButton1Click:Connect(function()
    Sound2:Play()
end)

script.Parent.MouseEnter:Connect(function()
    script.Parent.TextButton_Roundify_12px.BackgroundTransparency = 0
end)

script.Parent.MouseLeave:Connect(function()
    script.Parent.TextButton_Roundify_12px.BackgroundTransparency = 1
end)

Below here is the main script:

-- Locals --

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

-- Camera --

repeat wait() until Player.Character

Camera.CameraType = "Scriptable"
Camera.CFrame = game.Workspace.CameraPart.CFrame

0
It would solve the problem User#30567 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Right, the problem is with your Gui and not your script. On the ScreenGui properties, remove the check on ResetOnSpawn (or set it to false). Another thing is that you don't need to do the repeat until loop. It just wastes time and resources. You can use the CharacterAdded event.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
0
Thanks a lot I will try it right away!!! L30N_C 27 — 4y
Ad

Answer this question