Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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.

0
Could you accept the answer? Ziffixture 6913 — 5y

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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)
0
Thanks bro, I appreciate it. CaptainEmpyreus 0 — 5y
Ad

Answer this question