eb9h
(FembxyMilker)
November 5, 2020, 2:26pm
#1
I have a module script in ReplicatedStorage. It doesn’t give any errors, but it does not work.
Do I use require()
or game.InsertService
?
local Hotdog = {}
local PossibleColors = {
["red"] = Color3.fromRGB(255, 0, 0);
["orange"] = Color3.fromRGB(255, 140, 0);
["yellow"] = Color3.fromRGB(255, 239, 3);
["green"] = Color3.fromRGB(255, 0, 0);
["blue"] = Color3.fromRGB(0, 0, 255);
["purple"] = Color3.fromRGB(157, 0, 255);
["pink"] = Color3.fromRGB(255, 0, 251);
["black"] = Color3.fromRGB(0, 0, 0);
["white"] = Color3.fromRGB(255, 255, 255);
["tan"] = Color3.fromRGB(255, 223, 147);
}
function Hotdog.new(BUNCOLOR)
if BUNCOLOR == "red" then
local NEWHOTDOG = game.InsertService:LoadAsset(5919806610) -- Here
NEWHOTDOG.Name = "Hotdog"
NEWHOTDOG.Bun.Color = PossibleColors.red
elseif BUNCOLOR == "orange" then
-- not
elseif BUNCOLOR == "yellow" then
-- not
elseif BUNCOLOR == "green" then
-- not
elseif BUNCOLOR == "blue" then
-- not
elseif BUNCOLOR == "purple" then
-- not
elseif BUNCOLOR == "pink" then
-- not
elseif BUNCOLOR == "black" then
-- not
elseif BUNCOLOR == "white" then
-- not
elseif BUNCOLOR == "tan" then
-- not
end
end
return Hotdog
Yes, I have a module script with the name MainModule
inside of the Model
Where did I go wrong ?
Kaid3n22
(Kaiden)
November 5, 2020, 2:27pm
#2
add this after the local NEWHOTDOG
:
NEWHOTDOG = NEWHOTDOG:GetChildren()[1]
InsertService inserts a model with what was requested inside.
eb9h
(FembxyMilker)
November 5, 2020, 2:31pm
#3
Nothing still happened. Do I do this?
local Hotdog = {}
local PossibleColors = {
["red"] = Color3.fromRGB(255, 0, 0);
["orange"] = Color3.fromRGB(255, 140, 0);
["yellow"] = Color3.fromRGB(255, 239, 3);
["green"] = Color3.fromRGB(255, 0, 0);
["blue"] = Color3.fromRGB(0, 0, 255);
["purple"] = Color3.fromRGB(157, 0, 255);
["pink"] = Color3.fromRGB(255, 0, 251);
["black"] = Color3.fromRGB(0, 0, 0);
["white"] = Color3.fromRGB(255, 255, 255);
["tan"] = Color3.fromRGB(255, 223, 147);
}
function Hotdog.new(BUNCOLOR)
if BUNCOLOR == "red" then
local NEWHOTDOG = game.InsertService:LoadAsset(5919806610)
NEWHOTDOG = NEWHOTDOG:GetChildren()[1]
NEWHOTDOG.Name = "Hotdog"
NEWHOTDOG.Bun.Color = PossibleColors.red
elseif BUNCOLOR == "orange" then
-- not
elseif BUNCOLOR == "yellow" then
-- not
elseif BUNCOLOR == "green" then
-- not
elseif BUNCOLOR == "blue" then
-- not
elseif BUNCOLOR == "purple" then
-- not
elseif BUNCOLOR == "pink" then
-- not
elseif BUNCOLOR == "black" then
-- not
elseif BUNCOLOR == "white" then
-- not
elseif BUNCOLOR == "tan" then
-- not
end
end
return Hotdog
Kaid3n22
(Kaiden)
November 5, 2020, 2:33pm
#4
I assume the error is when you are trying to set the Bun’s Color. Use this:
BrickColor.new()
Instead of Color3.fromRGB()
as parts use BrickColor and not Color3.
1 Like
eb9h
(FembxyMilker)
November 5, 2020, 2:40pm
#5
I have an error, what’s an ient
It says InsertService
can’t load assets from it
local Hotdog = {}
local PossibleColors = {
["red"] = BrickColor.new("Really red");
["orange"] = BrickColor.new("Neon orange");
["yellow"] = BrickColor.new("Bright yellow");
["green"] = BrickColor.new("Bright green");
["blue"] = BrickColor.new("Baby blue");
["purple"] = BrickColor.new("Royal purple");
["pink"] = BrickColor.new("Pink");
["black"] = BrickColor.new("Black");
["white"] = BrickColor.new("White");
["tan"] = BrickColor.new("Buttermilk");
}
function Hotdog.new(BUNCOLOR)
if BUNCOLOR == "red" then
local NEWHOTDOG = game.InsertService:LoadAsset(5919806610)
NEWHOTDOG = NEWHOTDOG:GetChildren()[1]
NEWHOTDOG.Name = "Hotdog"
NEWHOTDOG.Bun.BrickColor = PossibleColors.red
elseif BUNCOLOR == "orange" then
-- not
elseif BUNCOLOR == "yellow" then
-- not
elseif BUNCOLOR == "green" then
-- not
elseif BUNCOLOR == "blue" then
-- not
elseif BUNCOLOR == "purple" then
-- not
elseif BUNCOLOR == "pink" then
-- not
elseif BUNCOLOR == "black" then
-- not
elseif BUNCOLOR == "white" then
-- not
elseif BUNCOLOR == "tan" then
-- not
end
end
return Hotdog
You need to use require(AssetID)
to use modulescripts from Roblox Website.
You don’t need to change Color3.fromRGB(R,G,B)
s in your code to BrickColor.new(BrickColorName)
s, both should work fine in this scenario.
You also don’t need that many elseif
s in your code either way. You can just do this if the only accepted colour is red:
if BUNCOLOR == "red" then
local NEWHOTDOG = require(5919806610)
NEWHOTDOG = NEWHOTDOG:GetChildren()[1]
NEWHOTDOG.Name = "Hotdog"
NEWHOTDOG.Bun.BrickColor = PossibleColors.red
else
end
If all colour are accepted you can just do this too:
function Hotdog.new(BUNCOLOR)
local NEWHOTDOG = require(5919806610)
NEWHOTDOG = NEWHOTDOG:GetChildren()[1]
NEWHOTDOG.Name = "Hotdog"
NEWHOTDOG.Bun.BrickColor = PossibleColors[BUNCOLOR]
end
You’re trying to call a modulescript that’s on Roblox Website from a localscript? I’m afraid that’s not possible, you have to add that modulescript to your game directly from the start to call it from the client, like ReplicatedStorage for example.
eb9h
(FembxyMilker)
November 5, 2020, 3:05pm
#9
will this work
local hotdog = workspace:WaitForChild(game.InsertService:LoadAsset(5919806610).Name)
nevermind I got the same error before the client error
I will look into it later
eb9h
(FembxyMilker)
November 5, 2020, 3:11pm
#10
all I can think of which is probably wrong is cloning a model from ServerStorage, but that’s going to be used in scripting
, not building in studio