What do you want to achieve?
To convert a Color3 into a string, and send it to the server so it can be saved
What is the issue?
I don’t know how to convert the Color3 into a string
What solutions have you tried so far?
I’ve tried using tostring
but it only prints one number from the Color3 value
local script
script.Parent.MouseButton1Click:Connect(function()
local allcolour = Color3.new(136, 255, 0)
local allcolournow = tostring(allcolour.R..",",allcolour.G..",",allcolour.B)
script.Parent.Parent.BeamColour.RemoteEvent:FireServer(allcolournow)
end)
server script
script.RemoteEvent.OnServerEvent:Connect(function(player,allcolournow)
local stats = player.leaderstats
stats.Skill1BeamColour.Value = allcolournow
print(allcolournow)
end)
2 Likes
Blockzez
(Blockzez)
November 3, 2020, 6:46pm
#2
tostring
only takes one argument, you passed 3 arguments so it’ll only convert the first argument to string.
As numbers automatically converts to string when doing mostly anything with them you don’t need tostring
in this instance.
local allcolournow = allcolour.R .. "," .. allcolour.G .. "," .. allcolour.B
Or alternatively, you can use tostring
for the Color3 value local allcolournow = tostring(allcolour)
3 Likes
thanks, turning the color3 itself into a string worked
script.Parent.MouseButton1Click:Connect(function()
local allcolour = Color3.new(136, 255, 0)
local allcolournow = tostring(allcolour)
script.Parent.Parent.BeamColour.RemoteEvent:FireServer(allcolournow)
end)
1 Like
Mimibienv
(Eldritch)
February 24, 2021, 10:08am
#4
use tostring()
to convert a value to a string
use tonumber()
to convert a value to a number