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

Why isn't my script creating the "ball" ?

Asked by 4 years ago

local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() wait(1) local Humanoid = Character.Humanoid or Character:WaitForChild("Humanoid") local mouse = Player:GetMouse() local ok = 0

function charge() if ok == 0 then ok = 40 local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://4364880762" local animationtrack = Humanoid:LoadAnimation(anim) animationtrack:Play() wait(0.2) local ball = Instance.new("Part") ball.Shape = "Ball" ball.CFrame = Humanoid.RightArm.CFrame * CFrame.new(0,-0.9,0) ball.Size = Vector3.new(1, 1, 1) ball.Parent = game.Workspace ball.Material = "Neon" ball.BrickColor = BrickColor.new("Blue") ball.Transparency = 0 ok = 3 end end

mouse.KeyDown:Connect(function(key) if key == "q" then charge() end end)

2
Bro put your code in a code block so it is easier to understand YahiaElramal_77 26 — 4y

1 answer

Log in to vote
-1
Answered by
xXLuka_XD 103
4 years ago
Edited 4 years ago

Don't use

mouse.KeyDown:Connect(function(key)
 if key == "q" then 
   charge() 
    end 
end)

You can use it, but UIS, or User input service is alot more efficient.

Here's an example of how UIS looks like:

local UIS = game:GetService('UserInputService')

UIS.InputBegan:connect(function(key,istyping)
  if key.KeyCode == Enum.KeyCode.Q then
         -- do whatever here
    end
end)

Also, next time when posting your issue, please, put your line of code in a code block!

0
This doesn't answer his question. ScuffedAI 435 — 4y
0
You don't avoid KeyDown because of "inefficiency", you avoid it because it is deprecated. Please don't give anymore bad answers I'm running out of downvotes downvoting other poor quality posts. programmerHere 371 — 4y
Ad

Answer this question