Hello, I want make a Helmet giver with a ClickDetector. So I want transform this script(touch) for use with ClickDetector. Thank for your help.
//local player = game.Players.LocalPlayer
//function onClick(player)
// local character = player.Character
// if character then
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Helmet") == nil then
local g = script.Parent.Parent.Helmet:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation" or "Part" then
local W = Instance.new("Weld")
W.Part0 = g.HeadPosition
W.Part1 = C[i]
local CJ = CFrame.new(g.HeadPosition.Position)
local C0 = g.HeadPosition.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.HeadPosition
g.HeadPosition.Transparency = 1
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Head
Y.Part1 = g.HeadPosition
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched)
//script.Parent.ClickDetector.MouseClick:connect(onClick)`

4 comments
You cannot clone a helmet to the localplayer because a player cannot clone things in a localscript you must need a remote event therefore your script is incorrect.
@JesseSong, I never said to put it in a LocalScript. Note: Client is able to clone things, but it won't replicate.
@JesseSong your grammar trash ---> input clown emoji
13:01:15.536 - Workspace..Button.Script:2: Expected identifier when parsing expression, got '02' don't work, and it's helmet not helemt