I have a local script inside of a text button, and here’s the script i used:
script.Parent.MouseButton1Click:Connect(function(Player)
local clone = game.ServerStorage.RainbowHalo:Clone()
clone.Parent = Player.Character
end)
Whenever you click the button, you get this error:
RainbowHalo is not a valid member of ServerStorage “ServerStorage”
The halo is an accessory in server storage. I’m not completely sure what’s happening.
There are two things that cause the error to occur.
MouseButton1Click doesn’t have a parameter. So you can define the player with LocalPlayer, which is only valid for local scripts.
local Player = game:GetService("Players").LocalPlayer
Clients have no access to ServerStorage. You may move it to ReplicatedStorage, where the things are replicated between both server and client.
local clone = game:GetService("ReplicatedStorage").RainbowHalo
And also, make sure to use the GetService method when getting services. Guaranteed.
local Player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local clone = game:GetService("ReplicatedStorage").RainbowHalo:Clone()
clone.Parent = Player.Character
end)