I have been using a soccer ball that I just have to touch to Kick it but what im really going for is a kick Button.
I have the anim and everything, but I just am clueless about the X Y Z script,
thanks for reading!
I have been using a soccer ball that I just have to touch to Kick it but what im really going for is a kick Button.
I have the anim and everything, but I just am clueless about the X Y Z script,
thanks for reading!
Use a proximity prompt
thats not really what I mean heres a vid
robloxapp-20220819-1104026.wmv (1.4 MB)
(I dont know why its a download file)
I’m stuck with the script
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
if key == "z" then
end
end)
As @ dummycide said, you can use a proximity prompt and when Its activated, you can get the characters look vector and apply a force to the ball, which I think Is a better option instead of having laggy players having an advantage or disadvantage.
You can also just make it so that it detects when the ball is hit, and then do the same exact thing to boost the ball.
oh, ok I get it But as I said its about the script thats got me
Could you explain more? If you don’t understand some parts,
A touched Function could be
local Ball = script.Parent
Ball.Touched:Connect(function(hit))
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local character = hit.Parent
end
end
As you can imagine mouse keys do not comprehend keyboard keys, so what you want to use is called UserInputService
Example:
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed) --input is what is passed to the callback function when the player interacts with the keyboard or the mouse, gameProcessed indicates whether or not the game is focused, it's a bool value and for example if the user is typing into a TextBox it will be false
if input.KeyCode == Enum.KeyCode.Z then --to check what key of the keyboard was pressed you can compare the input's KeyCode property with the desired Enum
--execute code here
end
end)
If you want to extend the functionality to mobile users too, you can dive into ContextActionService
heres a quick and easy way to do it:
to note you will have to do this on the server so its replicated to all clients
local anglepart = Instance.new("Part")
anglepart.CanCollide = false
anglepart.Anchored = true
anglepart.CFrame = CFrame.new(Player.HumanoidRootPart-Vector3.new(0,5,0), ball.Position)
ball.Velocity = anglepart.LookVector * 50 --this number can be replaced for the speed
anglepart:Destroy()
didn’t test this code but I hope it works, tell me if it doesn’t.
additionally looking at this instead of using the mouse consider using the UserInputService to get key inputs.
thats all I would like to know, I got my Keybind script, But Im stuck with what happens after I click “E”
after you press e you should,