function onButtonClicked() game.Workspace.character.Torso.Instance.new("Sparkles") end script.Parent.MouseButton1Click:connect(onButtonClicked)
When the TextButton is clicked, sparkles should appear in the player who clicked torso but it doesn't work :(
In your script, you should be getting the error Instance is not a valid member of Torso. This is because you can not go straight into making a new object when you're in the location. You want to make the new object first, then place it in the desired location. Fortunately, there is an optional second argument to Instance.new()
that allows you to set a location for the object. You would also get the error, character is not a valid member of workspace. This is because in workspace, there is no model or object named character. Your script should look more like.
--Put in a local script for LocalPlayer to work. function onButtonClicked() Instance.new("Sparkles", game.Players.LocalPlayer.Character.Torso) end script.Parent.MouseButton1Click:connect(onButtonClicked)
Check out this wiki article if I did not explain Instance.new well enough.
You can also check here to see how LocalPlayer works.
You have to insert a click detector into the part
script.Parent.ClickDetector.MouseClick:connect(onButtonClicked)
Here is a script for spawing one
Instance.new("ClickDetector",game.Workspace:FindFirstChild("PartNameGoesHere")