Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can anybody tell me why this isn't working?

I am trying to make a script so that when the player clicks , it will create a ball/sphere from their head location ,but it does nothing when i test it.

here is the script

if mouseButton1OnClick:connect = true
then function attack	
function()attack = 
	
end
attack = game.Players.LocalPlayer.Character:findFirstChild("Head")
	Instance.new("Part")
	P=Part.Properties		
	P.Properties.Anchored=false
	P.Vector3= 0,0,2
	P.CanCollide=true
	P.Shape=Ball
	P.Size=5,5,5
	P.Material= "SmoothPlastic"
	P.BrickColor="ReallyRed"
	P.transparency=.4
	wait(5)
end

2 answers

✓ Accepted answer

A lot of mistakes. Let me fix it:

script.Parent.MouseButton1Down:connect(function()
Local head = game.Players.LocalPlayer.Character:FindFirstChild("Head")
If head then
    Local p = Instance.new("Part")
    P.Anchored=false
    P.Size = Vector3.new(5,5,5)
    P.CanCollide=true
    P.Shape = "Ball"
    P.CFrame = head.Position + Vector3.new(0,3,0)
    P.Material= "SmoothPlastic"
    P.BrickColor="Really red"
    P.Transparency= 0.4
    wait(5)
End
end)

Script must be a LocalScript to use LocalPlayer.

4 comments

1

Your capitalisation of Lua keywords will break the script.

0

Line 2, line 3, and line 14 -- "local", "if", and "end", respectively.

0

Thanks,it keep saying "expected '=' got head (line 2)

0

Sorry about my errors, it was rushed.

This must be placed in a Local Script, and be replicated to a player service, like PlayerGui or Backpack.

player = game:GetService('Players').LocalPlayer
mouse = player:GetMouse()

mouse.Button1Down:connect(function()
	if (player.Character) and (player.Character:FindFirstChild('Head')) then
		local part = Instance.new('Part', game.Workspace)
		part.Size = Vector3.new(5, 5, 5)
		part.Vector3 = Vector3.new(0, 0, 2)
		part.Shape = Enum.PartType.Ball
		part.Material = Enum.Material.SmoothPlastic
		part.Transparency = .4

		wait(5)
		part:Destroy()
	end
end)

1 comment

0

Thanks got it to create the part, but it isnt adding the properties (color,material,shape,transparency,etc.)

This discussion is preserved as it was. New answers, comments, and votes are closed.