Im trying to make this script where it changes your character when you click a button, but for some reason. It wont let me grab the StarterCharacter

##Script:

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	game:GetService("ServerStorage"):FindFirstChild('Mouse'):WaitForChild('StarterCharacter'):Clone().Parent = game:GetService('StarterPlayer')
	player:LoadCharacter()
	script.Parent.Parent.Visible = false
end)

The error is

Players.(Player Name).PlayerGui.ScreenGui.Frame.TextButton.LocalScript:3: attempt to index nil with 'WaitForChild'

3 comments

0

How do i fix that?

0

The Client cannot access Server-sided assets, consider moving the Model to a replicated container.

0

That makes a lot of sense.. Thanks!