Why the script doesnt work?

Expexted Result:
when mouse click, an image spawned at the position that the mouse clicked

  1. What is the issue?
    there is no images cloned but it ran through the entire script and print “Ya”
local players = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local Mouse = players:GetMouse()
Mouse.Button1Down:Connect(function()
	players.leaderstats.Tockens.Value +=1
	local po = UIS:GetMouseLocation()
	local i = game.StarterGui.ScreenGui.ImageLabel:Clone()
	i.Position = UDim2.new(0,po.X,0,po.Y)
	i.Parent = game.StarterGui.ScreenGui
	i.Visible = true
    print("Ya")
end)

Can someone please help me I have been struggling with this for 3 hours

  1. For UI mouse functions, use (instance).MouseButton1Click.

  2. You should access PlayerGui instead of StarterGui. Making changes in StarterGui while playing doesn’t replicate to the client. You can get PlayerGui by doing player:WaitForChild(“PlayerGui”).

  3. You can’t edit leaderstats from a local script.

1 Like

Thank you very much! I fixed it!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.