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

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

Asked by 6 years ago
Edited 6 years ago

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
0
To test if a part exist, you have to use "if PARTHERE then" Leamir 3138 — 6y
0
please upvote SLENDERMANCLONE -27 — 6y

2 answers

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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!

0
that didnt work SLENDERMANCLONE -27 — 6y
0
Edited, try now Leamir 3138 — 6y
0
Edited(Again) and tested, Now works Leamir 3138 — 6y
0
that didnt work either, im trying to make my own one but it will only work on the blue spawns SLENDERMANCLONE -27 — 6y
View all comments (5 more)
0
Where are the spawns located? Workspace? Leamir 3138 — 6y
0
they are in a model SLENDERMANCLONE -27 — 6y
0
the model is under workspace SLENDERMANCLONE -27 — 6y
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... Leamir 3138 — 6y
0
Script added! Hope it works, don't need to change any vars Leamir 3138 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
0
sorry i asked he wrong question SLENDERMANCLONE -27 — 6y

Answer this question