Yeah so that works, the thing that bothers me is that my controlls dont work and i have not a single idea of why, here is the controll script:
local Ball = game.Workspace:WaitForChild("Ball")
local Char = Ball.Parent
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
local currentVelocity = Ball.Velocity
local speed = 20
if input.KeyCode == Enum.KeyCode.A then
Ball.Velocity = Vector3.new(-speed, currentVelocity.Y, currentVelocity.Z)
elseif input.KeyCode == Enum.KeyCode.D then
Ball.Velocity = Vector3.new(speed, currentVelocity.Y, currentVelocity.Z)
end
end
end)
but the egg shaped ball is gone. Thank you very much.
I think you are looking in the wrong placeā¦
Get the player character.
Then when the user presses the key, look for the ball in the character. (It might not be there when the script first runs).
local Players = game:GetService('Players')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local UserInputService = game:GetService('UserInputService')
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Ball = Character:WaitForChild('Ball')
local BV = Instance.new('BodyVelocity')
local Speed = 20
BV.MaxForce = Vector3.new(math.huge, 0, math.huge)
BV.Velocity = Vector3.new(Speed, 0, 0)
BV.Name = 'BALL_Velocity'
BV.Parent = Ball
UserInputService.InputBegan:Connect(function(InputObject, GPE)
if not GPE then
local KeyCode = InputObject.KeyCode
if KeyCode == Enum.KeyCode.A then
BV.Velocity += Vector3.new(0, 0, Speed)
elseif KeyCode == Enum.KeyCode.D then
BV.Velocity += Vector3.new(0, 0, -Speed)
end
end
end)
UserInputService.InputEnded:Connect(function(InputObject, GPE)
if not GPE then
local KeyCode = InputObject.KeyCode
if KeyCode == Enum.KeyCode.A or KeyCode == Enum.KeyCode.D then
BV.Velocity = Vector3.new(Speed, 0, 0)
end
end
end)
Also if ur contgrols were wrking before u tried the other code and allat maybe revert back to a working version and set size to a cube again and see ift hat works
itās a server sided script parented in server script service, the reason for that is that when it was a local script, the ball only moved on the client and the whole games mechanic just wouldnāt work, so thatās why I made it a server sided script but yes Iām sure that the ball Iām tryna move is in the character
userinputservice and stuff doesnt work from the server script, so maybe set the network ownership of the ball to the player (by parenting the ball to the character) and make the server script local again