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

How can I make a script in a loop stop at a certain point?

Asked by 6 years ago

Ik the title is misleading but there is no way to say this otherwise.

so I have a script that when a player clicks on a certain part of the body will change what part they are editing but no matter the part selected it only will edit the head of the player.

--Variables
local h = script.Parent.Parent.Parent.edit_label.Part.Value
--head
if h == "Head" then
    script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.Data.headcolor.Value = script.Parent.Name
        script.Parent.Parent.Parent.Hat.BackgroundColor3 = Color3.fromRGB(27, 42, 53)
    end)
end
--torso
if h == "Torso" then
    script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.Data.headcolor.Value = script.Parent.Name
        script.Parent.Parent.Parent.Hat.BackgroundColor3 = Color3.fromRGB(27, 42, 53)
    end)
end
--larm
if h == "Larm" then
    script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.Data.headcolor.Value = script.Parent.Name
        script.Parent.Parent.Parent.Hat.BackgroundColor3 = Color3.fromRGB(27, 42, 53)
    end)
end
--rarm
if h == "Rarm" then
    script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.Data.headcolor.Value = script.Parent.Name
        script.Parent.Parent.Parent.Hat.BackgroundColor3 = Color3.fromRGB(27, 42, 53)
    end)
end
--lleg
if h == "Lleg" then
    script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.Data.headcolor.Value = script.Parent.Name
        script.Parent.Parent.Parent.Hat.BackgroundColor3 = Color3.fromRGB(27, 42, 53)
    end)
end
--rleg
if h == "Rleg" then
    script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.Data.headcolor.Value = script.Parent.Name
        script.Parent.Parent.Parent.Hat.BackgroundColor3 = Color3.fromRGB(27, 42, 53)
    end)
end

0
i want you to read this, then correct your grammar for me. "so I have a script that when a player clicks on a certain part of the body will change what part they are editing but no matter the part selected it only will edit the head of the player." GIassWindows 141 — 6y
0
You need to explain the issue a bit better. SchonATL 15 — 6y
0
You didn't change "headcolor" or "Hat" in any of the other if statements. You also don't need a different click connection for every if statement. call23re2 87 — 6y
0
I did change it before this with another script that i had scrapped and gave the same results VeryDarkDev 47 — 6y
View all comments (5 more)
0
this post is basically dead ;c VeryDarkDev 47 — 6y
0
You want to use if and elseif. And it seems to only be setting the headcolor value. There's so much repetition that you could shorten everything to about 6 lines of code MooMooThalahlah 421 — 6y
0
Where is this script located; where is it parented to? MooMooThalahlah 421 — 6y
0
Not gonna answer bc I barely looked but since you make a permanent connection every time those connections interfere. you need to fix that cabbler 1942 — 6y

Answer this question