Heya, I’m making an undertale game and I’m making atacks for sans. I’m making the attack go to where the player’s mouse is (Haven’t done that yet but working on it). This attack is the bone barrage.
I haven’t got it to work. Here it my script: (Local script in the tool)
local RS = game:GetService("RunService")
local U = game:GetService("UserInputService")
local C = workspace.CurrentCamera
local item = nil
local P = game.Players.LocalPlayer
task.wait()
local function MRayCast()
local MP = U:GetMouseLocation()
local MR = C:ViewportPointToRay(MP.X, MP.Y)
local rR = workspace:Raycast(MR.Origin, MR.Direction * 1000)
return rR
end
local function GRP()
local x = math.random(1,3)
local y = math.random(1,3)
local z = math.random(1,3)
return Vector3.new(x,y,z)
end
U.InputBegan:Connect(function(input, processed)
if processed then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 and script.Parent.Parent ~= game.Players.LocalPlayer.Backpack then
workspace.Attacks.BoneAttack.Bone.CFrame = P.Character.PrimaryPart.CFrame + GRP()
workspace.Events.Bone:FireServer()
end
end)
RS.RenderStepped:Connect(function()
local R = MRayCast()
if R and R.Instance then
item = R.Instance
end
end)
This is my other script located in a folder where the bones are. (Server-Side)
while true do
for _,v in ipairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") and script.Parent.BoneTime.Value == true then
print("AA")
v.Position = v.Position + Vector3.new(2.3,0,0)
end
end
wait()
end
The problem is that when the position is assigned in the local script, the bones just go back to where they were moving. Video: