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

How to stop localscript from being created on respawn after destroyed?

To expand upon my question: I have a localscript that does exactly what I want it to do and after a certain value is true it destroys itself. I thought that I figured out how to remove a localscript completely and not have it come back after a player's death. However, whenever they respawn the localscript is recreated back into the startergui automatically How would I prevent this from happening?

local player = game.Players.LocalPlayer
local character = player.Character
local camera = workspace.CurrentCamera

repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = workspace.CameraPos_MainMenu.CFrame
local blur = Instance.new("BlurEffect",camera)
blur.Size = 10



if camera.CameraType == Enum.CameraType.Scriptable then wait()
	script:Destroy()
end

2 comments

0

just put your localscript disabled and enable it when player joined, use PlayerAdded event.

0

i can't use the PlayerAdded event because it is all supposed to be in a local script.

1 answer

A simple way is simply by making another script and putting it in serverscriptservice. Put the gui in serverstorage or replicated storage and then duplicate into the player. An example is

scriptname = game.ReplicatedStorage.scriptname --the gui can't be called "script"
game.Players.PlayerAdded:Connect(function(plr)
	local scriptname2 = scriptname:Clone()
	scriptname2.Parent = plr.PlayerGui
end)

This will clone the gui if its in replicated storage and it goes to the playergui

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