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

Can hit.Parent work with a click?

Asked by
Prioxis 673 Moderation Voter
10 years ago

So say I click something and I want it to insert a Shirt and pants into that character would I do

Function onClicked()
local S = Instance.new("Shirt")
S.Parent = hit.Parent -- part I need help on
end

3 answers

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

You never justified what hit was. If you want to use this you would first have to declare the variable hit.

function onClicked(hit) -- See that hit in there? That variable tells the script who clicked it.
local S = Instance.new("Shirt")
S.Parent = hit.Parent
end

The variable doesn't have to be hit either, you could make it clicked, player, afuaguf, or anything else at all.

Ad
Log in to vote
0
Answered by
Kozero 120
10 years ago

If you are talking about the event MouseClick then you need a connection line so it can be activated by the player who activates it.which then connects the function for example: Be aware the MouseClick event can only be activated by using the object ClickDetector so put it in the brickthat will be used for clicking.

function Clicker()
local Part=Workspace.Part
Part:Destroy()
end
script.Parent.ClickDetector.MouseClick:connect(Clicker)
Log in to vote
-2
Answered by 10 years ago

Put it in the brick at bottom put..Actually here

function onClicked()
local S = Instance.new("Shirt")
S.Parent = hit.Parent -- part I need help on
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

That should work tell me Remember! Put a ClickDetector in the brick.

0
You didn't write the function between the arguments in the method at the connection line. Kozero 120 — 10y

Answer this question