function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then -- Verify that a actual player hit it
local clone = game.Lighting.Arrow:clone()
move = script.Parent.Parent.Arrow
move.CFrame = CFrame.new(-8.5, 3.5, -0.5)
Arrow = script.Parent -- Object Tree location of part
speed = .1 -- Speed of the movements, the lower the number, the faster and more smooth
distance = 10 --The distance to move along the axis
timestorun = distance * 10 -- Times to run, don't change this as it allows for smooth transitions
for i = 1, timestorun do -- i represents the index or current position of the loop, it starts at one and goes to whatever the times to run is, meaning it will run that many times
wait(speed) -- Wait for the designated speed time
part.CFrame = CFrame.new(part.Position + Vector3.new(0.1,0,0)) -- Change the CFrame by 0.1 to allow for a smooth transition
end -- End the loop
end -- End the first function
end
script.Parent.Touched:connect(onTouched)
In this code when a player touches a brick called: Part It will clone the part: Arrow from the lighting then teleport it to a position and finally it moves 10 studs along the X axis, but it doesn't work when testing in play solo (and on its actual ROBLOX game) it has a problem with the 4th line saying it is not in the workspace.
Please annotate any changes made.
Thank you in advance.

1 comment
The second part is text btw just glithced out as code