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

how do i detect if one of the teams spawns were deleted from falling?

i did this script to see if one of the models are gone but it isnt working

if Model2.Bluespawns == false then
		print ("Red won")
		TextLabel.Parent = ScreenGui
	TextLabel.Size = UDim2.new(0,150,0,50)
	TextLabel.Position = UDim2.new(0,125,0,0)
	ScreenGui.Parent = game.StarterGui
	TextLabel.Text = "Red won"
	end
	
	if Model2.Redspawns== false then
		print("Blue won")
	TextLabel.Parent = ScreenGui
	TextLabel.Size = UDim2.new(0,150,0,50)
	TextLabel.Position = UDim2.new(0,125,0,0)
	ScreenGui.Parent = game.StarterGui
	TextLabel.Text = "Blue won"
	end

2 comments

0

To test if a part exist, you have to use "if PARTHERE then"

0

please upvote

2 answers

✓ Accepted answer

Hello, SLENDERMANCLONE!

Try this (EDITED AGAIN) script:

local Model2
for i,part in pairs(game.Workspace:GetDescendants()) do
	if part.Name == "Bluespawns" or part.Name == "Redspawns" then
		Model2 = part.Parent
		break
	end
end

while wait() do
	if not Model2:FindFirstChild("Bluespawns") then
   		print ("Red won")
		for i,plr in pairs(game.Players:GetChildren()) do
			ScreenGui = Instance.new("ScreenGui")
			TextLabel = Instance.new("TextLabel")
   			TextLabel.Parent = ScreenGui
   			TextLabel.Size = UDim2.new(0,150,0,50)
    		TextLabel.Position = UDim2.new(0,125,0,0)
    		ScreenGui.Parent = plr.PlayerGui
    		TextLabel.Text = "Red won"
			wait(10)
			ScreenGui:Destroy()
		end
	elseif not Model2:FindFirstChild("Redspawns") then
		print("Blue won")
		for i,plr in pairs(game.Players:GetChildren()) do
    		ScreenGui = Instance.new("ScreenGui")
			TextLabel = Instance.new("TextLabel")
   			TextLabel.Parent = ScreenGui
   			TextLabel.Size = UDim2.new(0,150,0,50)
    		TextLabel.Position = UDim2.new(0,125,0,0)
    		ScreenGui.Parent = plr.PlayerGui
    		TextLabel.Text = "Blue won"
			wait(10)
			ScreenGui:Destroy()
		end
	end
 end

Good luck with your games!

9 comments

0

that didnt work

0

Edited, try now

0

Edited(Again) and tested, Now works

0

that didnt work either, im trying to make my own one but it will only work on the blue spawns

0

Where are the spawns located? Workspace?

0

they are in a model

0

the model is under workspace

0

so you have to change the var "Model2" to the correct location, if I understood correctly, it have to be "game.Workspace.Model2" I'll make a script to detect model2's location soon...

0

Script added! Hope it works, don't need to change any vars

Try this

local bluespawn = Model2:FindFirstChild("Bluespawns")
local redspawn = Model2:FindFirstChild("Redspawns")

if bluespawn then
    print("Red won")
    TextLabel.Parent = ScreenGui
    TextLabel.Size = UDim2.new(0,150,0,50)
    TextLabel.Position = UDim2.new(0,125,0,0)
    ScreenGui.Parent = game.StarterGui
    TextLabel.Text = "Red won"
end

if redspawn then
    print("Blue won")
    TextLabel.Parent = ScreenGui
    TextLabel.Size = UDim2.new(0,150,0,50)
    TextLabel.Position = UDim2.new(0,125,0,0)     
    ScreenGui.Parent = game.StarterGui
    TextLabel.Text = "Blue won"
end

1 comment

0

sorry i asked he wrong question

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