I am trying to change color of a suitcase from a button but it does this every time
sometimes it doesnt even work.
script:
local configurations = require(script.Parent.Configure)
script.Parent.AncestryChanged:Connect(function(child,Newparent)
if not Newparent.Parent.Name == "Workspace" then
if game.Players:GetPlayerByUserId(Newparent.Parent.UserId) then
local default1 = configurations.defaultColor1
local default2 = configurations.defaultColor2
local default3 = configurations.defaultColor3
local default4 = configurations.defaultColor4
local freeFullAccess = configurations.freeFullColorAccess
local gamepassid = configurations.gamepassIdForFullColorAccess
local plr = Newparent.Parent
local mps = game:GetService("MarketplaceService")
script.Parent.Frame.Default1.BackgroundColor3 = Color3.fromRGB(configurations.defaultColor1)
script.Parent.Frame.Default2.BackgroundColor3 = Color3.fromRGB(configurations.defaultColor2)
script.Parent.Frame.Default3.BackgroundColor3 = Color3.fromRGB(configurations.defaultColor3)
script.Parent.Frame.Default4.BackgroundColor3 = Color3.fromRGB(configurations.defaultColor4)
if freeFullAccess == true or gamepassid == 0 then
script.Parent.Frame.FullColors.Lock.Visible = false
else
if mps:UserOwnsGamePassAsync(plr.UserId,gamepassid) then
script.Parent.Frame.FullColors.Lock.Visible = false
else
script.Parent.Frame.FullColors.Lock.Visible = true
end
end
else
print("Not valid player.. Waiting to be parented to a player...")
end
end
end)
Config script:
local config = {}
config.freeFullColorAccess = true -- Will full color be free? If yes then set to true if no then set to false.
config.gamepassIdForFullColorAccess = 0 -- If freeFullColorAccess is false then insert a gamepass id here that people must buy to use full colors! (If left at 0 freeFullColorAccess will be turned on by default!)
config.defaultColor1 = Color3.fromRGB(255, 0, 0)
config.defaultColor2= Color3.fromRGB(0, 0, 255)
config.defaultColor3 = Color3.fromRGB(0, 255, 0)
config.defaultColor4 = Color3.fromRGB(255, 255, 0)
return config
Wouldn’t this just do the same exact thing? just a bit more efficient than however you did it.
local Event = script.Parent.ChangeColor
local GamepassId = 0
local MarketPlace = game:GetService("MarketplaceService")
Event.OnServerEvent:Connect(function(Plr, Color)
if type(Color) == "string" and MarketPlace:UserOwnsGamePassAsync(Plr.UserId, GamepassId) == true then
for _, Object in ipairs(script.Parent:GetChildren()) do
if Object.Name == "Color" and Object:IsA("BasePart") then
Object.BrickColor = BrickColor.new(Color)
end
end
end
end)
I made a few script changes like changing to brickcolor.
Receiving Script:
script.Parent.ChangeColor.OnServerEvent:Connect(function(color)
for _,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "MeshPart" then
if v.Name ~= "Screws" and v.Name ~= "Handle" and v.ClassName == "MeshPart" and v.Name ~= "Wheels" and v.Name ~= "LockMain" then
v.BrickColor = BrickColor.new(color)
end
end
end
end)
Configure script:
local config = {}
config.freeFullColorAccess = true -- Will full color be free? If yes then set to true if no then set to false.
config.gamepassIdForFullColorAccess = 0 --If freeFullColorAccess is false then insert a gamepass id here that people must buy to use full colors! (If left at 0 freeFullColorAccess will be turned on by default!)
config.defaultColor1 = "Really red"
config.defaultColor2= "Deep blue"
config.defaultColor3 = "Bright green"
config.defaultColor4 = "Bright yellow"
return config
Fire Script:
script.Parent.TextButton.MouseButton1Click:Connect(function()
local module = require(script.Parent.Parent.Parent.Configure)
local plr = game.Players.LocalPlayer
plr.Character.Suitcase.ChangeColor:FireServer(module.defaultColor4)
end)