getting an error as stated above, "attempt to index nil with ‘Clone’
the thing i am trying to clone is a BoolValue inside of a folder in ReplicatedStorage:
script inside of server script service:
local e = game.ReplicatedStorage.Events.Setup.ColourSet
local storage = game.ReplicatedStorage.Colours
e.OnServerEvent:Connect(function(player)
local colour = player.PlayerGui.Spinner.Background.Results.Text
local item = storage:FindFirstChild(colour):Clone()
item.Parent = player.Character
end)
it means it isn’t able to find colour inside the folder so just add this:
if storage:FindFirstChild(colour) then
local colour = player.PlayerGui.Spinner.Background.Results.Text
local item = storage:FindFirstChild(colour):Clone()
item.Parent = player.Character
end
local e = game.ReplicatedStorage.Events.Setup.ColourSet
e.OnServerEvent:Connect(function(player)
local colour = player.PlayerGui.Spinner.Background.Results.Text
local item = game.ReplicatedStorage.Colours:FindFirstChild(colour):Clone()
item.Parent = player.Character
end)
no… the text is changed locally and it works fine, once it is changed i fire an event and pick it up on the server and then find the colour based on the text in the gui.
You have to change the text not locally or get the text locally. One way you can get the text locally is using a RemoteFuntion.
Example:
LocalScript in StarterPlayerScripts
local e = game.ReplicatedStorage.GetColor
local player = game.Players.LocalPlayer
e.OnClientInvoke = function()
return player.PlayerGui.Spinner.Background.Results.Text
end
Then in your script:
local e = game.ReplicatedStorage.Events.Setup.ColourSet
local storage = game.ReplicatedStorage.Colours
local GetColor = game.ReplicatedStorage.GetColor
e.OnServerEvent:Connect(function(player)
local colour = GetColor:InvokeClient()
local item = storage:FindFirstChild(colour):Clone()
item.Parent = player.Character
end)