So i have some code that sets values inside of the player to rgb values. one value for each variable “r” “g” “b” and it isn’t working. Please help!
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Red = game.Players.LocalPlayer:WaitForChild("ShellColor").r.Value
local Green = game.Players.LocalPlayer:WaitForChild("ShellColor").g.Value
local Blue = game.Players.LocalPlayer:WaitForChild("ShellColor").b.Value
local ShellOuter = player.Character:WaitForChild("ShellOuter")
local ShellInner = player.Character:WaitForChild("ShellOuter")
local MarketplaceService = game:GetService("MarketplaceService")
local GAMEPASS_ID = 848500558
local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
if ownsGamepass == true then
ShellInner = Color3.fromRGB(Red, Green, Blue)
ShellOuter = Color3.fromRGB(Red, Green, Blue)
end
This is server script in StarterCharacterScripts
I have a local script inside of a textbox ui (3 of them actually) for each rgb value. idk if these might actually be the problem
local Blue = game.Players.LocalPlayer:WaitForChild("ShellColor").b
script.Parent.Changed:Connect(function()
Blue.Value = script.Parent.Text
end)
Try changing these two things, and tell me if it works:
Server scripts cannot get the player via game.Players.LocalPlayer. Use game.Players.PlayerAdded to get each individual player instead.
The ShellInner variable is the same as the ShellOuter variable, just a minor bug I saw. (Don’t know if it’s intentional or not.)
Here’s an example if it helps:
local marketPlaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local gamepassID = 848500558
local function changeShellColor(player)
local red = player:WaitForChild("ShellColor").r.Value
local green = player:WaitForChild("ShellColor").g.Value
local blue = player:WaitForChild("ShellColor").b.Value
local character = player.Character or player.CharacterAdded:Wait()
local shellOuter = player.Character:WaitForChild("ShellOuter")
local shellInner = player.Character:WaitForChild("ShellInner")
local ownsGamepass = marketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassID)
if ownsGamepass == true then
shellInner = Color3.fromRGB(red, green, blue)
shellOuter = Color3.fromRGB(red, green, blue)
end
end
players.PlayerAdded:Connect(function(player)
changeShellColor(player)
end)
Placing a folder in StarterPlayer doesn’t replicate to the player when playing the game. Try putting the ShellColor folder into the server script and then copy this piece of code into the server script:
players.PlayerAdded:Connect(function(player)
script.ShellColor:Clone.Parent = player
changeShellColor(player)
end)
Also, just to ensure it’s a number, do this when setting the values of the NumberValue:
script.Parent.Changed:Connect(function()
local Number = tonumber(script.Parent.Text)
if Number == nil then return end
Blue.Value = Number
end)
idk… still isn’t working. anything else that i might be doing wrong? or could try? does it help to know that it’s a custom character? i assume you already knew that from where i’m trying to get the shell from
local marketPlaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local gamepassID = 848500558
local function changeShellColor(player)
local red = player:WaitForChild("ShellColor").r
local green = player:WaitForChild("ShellColor").g
local blue = player:WaitForChild("ShellColor").b
local character = player.Character or player.CharacterAdded:Wait()
local shellOuter = player.Character:WaitForChild("ShellOuter")
local shellInner = player.Character:WaitForChild("ShellInner")
local ownsGamepass = marketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassID)
if ownsGamepass == false then
shellInner = Color3.fromRGB(red, green, blue)
shellOuter = Color3.fromRGB(red, green, blue)
end
end
players.PlayerAdded:Connect(function(player)
script.ShellColor:Clone().Parent = player
changeShellColor(player)
end)
local Blue = game.Players.LocalPlayer.b
script.Parent.Changed:Connect(function()
local Number = tonumber(script.Parent.Text)
if Number == nil then return end
Blue.Value = Number
end)
local Blue = game.Players.LocalPlayer:WaitForChild('ShellColor').b
script.Parent.Changed:Connect(function()
local Number = tonumber(script.Parent.Text)
if Number == nil then return end
Blue.Value = Number
end)
What I changed was the local Blue = game.Players.LocalPlayer.b and changed it to local Blue = game.Players.LocalPlayer:WaitForChild('ShellColor').b since in the code above demonstrates that the numbervalue ‘b’ is inside a folder named ShellColor.