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

Can anybody tell me why this isn't working?

Asked by
Sineo 5
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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.

1
Your capitalisation of Lua keywords will break the script. User#6546 35 — 9y
0
Line 2, line 3, and line 14 -- "local", "if", and "end", respectively. DeadToMe 105 — 9y
0
Thanks,it keep saying "expected '=' got head (line 2) Sineo 5 — 9y
0
Sorry about my errors, it was rushed. TheDeadlyPanther 2460 — 9y
Ad
Log in to vote
0
Answered by
DeadToMe 105
9 years ago

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)
0
Thanks got it to create the part, but it isnt adding the properties (color,material,shape,transparency,etc.) Sineo 5 — 9y

Answer this question