Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

if you click a GUI button, a trail will be inserted into player but it doesnt insert, can you help?

game.Players.PlayerAdded:Connect(function(plr)

plr.CharacterAdded:Connect(function(char)

script.Parent.Parent.StarterGui.ShopMenu.ScrollingFrame.rainbow.MouseButton1Click: Connect(function()

local trail = game.ServerStorage["rainbow"]

local plrTrail = trail:Clone()

plrTrail.Parent = char.HumanoidRootPart

plrTrail.Attachment0 = char.Head.FaceFrontAttachment

plrTrail.Attachment1 = char.Torso.WaistBackAttachment

end)

end)

end)

This is the script, i really don't know how to fix it. I've tried alot of different things. Please help me.

1 comment

0

Could you accept the answer?

1 answer

StarterGui is a replication Service. It is used to transfer the UI content into the Connected User's personal GUI Service, that of which is titled 'PlayerGui'. Attempting to reach any descendants of said replication service, for input, will not do you any good. To get the desired local input, you must reference the authentic home of the GUI.

This can be done like so:

local Player = game:GetService("Players").LocalPlayer
Player.PlayerGui.Gui.MouseButton1Click:Connect(function()
	print("Hello World!")
end)

1 comment

0

Thanks bro, I appreciate it.

This discussion is preserved as it was. New answers, comments, and votes are closed.