local BadgeService = game:GetService("BadgeService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GUIs = ReplicatedStorage:WaitForChild("GUIs")
local HealthGui = GUIs:WaitForChild("HealthGui")
local PlayerUserText = HealthGui:WaitForChild("PlayerUsername")
local Pre_Alpha_Tester_Text = GUIs:WaitForChild("Pre-Alpha-Tester-Text")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Enable_Blur_Remote = Remotes:WaitForChild("Enable_Blur")
local BadgeID = 349466981534156
local function ForceField(character)
local ForceField = Instance.new("ForceField")
ForceField.Visible = false
ForceField.Parent = character
end
local function Health_Bar(player, character)
local Head = character:WaitForChild("Head")
local HealthGui_Clone = HealthGui:Clone()
local PlayerUser = HealthGui_Clone:WaitForChild("PlayerUsername")
HealthGui_Clone.Parent = Head
PlayerUser = player.Name
if not BadgeService:UserHasBadgeAsync(player.UserId, BadgeID) then return end
Pre_Alpha_Tester_Text:Clone().Parent = HealthGui_Clone
end
local function NoCollision(character)
for i, v in character:GetDescendants() do
if v:IsA("BasePart") then
v.CollisionGroup = "Players"
else
continue
end
end
end
local function Dash_Key_SetUp(player)
local DashKey = Instance.new("StringValue")
DashKey.Name = "Dash_Key"
DashKey.Value = "Q"
DashKey.Parent = player
end
game.Players.PlayerAdded:Connect(function(player)
Dash_Key_SetUp(player)
player.CharacterAdded:Connect(function(character)
NoCollision(character)
ForceField(character)
Health_Bar(player, character)
-- Check if player has successfully loaded in and if not then disable every character script here
end)
end)
Whenever the player first joins the game, I want to disable their character scripts until the press the play button in the main menu. However, when the player dies, the script will automatically disable their character scripts. I don’t want it to do that. I want it to check if the player has fully loaded in the game so it won’t disable their character scripts. Is there any way to fix this?
Hey!
Maybe try using a boolvalue on run. and detect that way.
Also avoid Disabling Scripts on Death: Only disable character scripts on initial join, not on respawn.
That’s what I’m trying to do. Disabling scripts only on inital join and not on player death. Anyways, I’m not sure how a boolean value will work? I want the disabling character scripts to NOT run when the player has pressed the play button on the menu
hey to check when a character has loaded in or respawned, you can use player.characteradded. if you want to delay the spawning of the character, you can disable characterautoloads and then use player load character
Instead of disabling character loading, you can put a Script in the UI (Assuming it’s not added to the PlayerGui from the client) that disables the Character scripts until the play button is pressed. And you can disable ScreenGui.ResetOnSpawn on your UI, which will make the script not run multiple times.
Wait what do you mean by that? The Menu is in StarterGui and if the player resets during the menu, will the menu not appear anymore. I also don’t know how to make a script for that
ohhhhh ic. ok building off of what @IanSliders said, you could have screengui.resetonspawn on for the menu gui, but when the play button is clicked, you disable it
true so that if the player resets while on the menu, it reappears. then when they click play, you turn the reset on spawn off so they never see it again
How do I make it so that their character scripts won’t be disabled though after they press the play button? (Server script in server script service disables them)
Starting off with ResetOnSpawn as true, you could make a Script in the menu UI:
local MenuUI = script.Parent
local PlayButton = MenuUI.Path.To.PlayButton
PlayButton.MouseButton1Down:Connect(function()
MenuUI.ResetOnSpawn = false
end)
And then check in the character script whether or not the UI’s ResetOnSpawn is enabled and if it’s disabled you can then enable the scripts in the character
Local script or server script? Does this script change the reset on spawn in the starter gui or the player’s gui? (When the player presses the play button there is a debris on the menu)
A server script, otherwise it wouldn’t be readable from the ServerScriptService script whether or not the UI has ResetOnSpawn
Also, it sets the ResetOnSpawn in the player’s gui only
so you could maybe check player.characteradded then set yourscript.Enabled = not menugui.resetonspawn or you could have the scripts defaulted to enabled and disable it when they join the game perhaps.
The charcter script disabling runs whenever the player (more specifically when their charcter gets added) joins though. I’m not sure if it will work?