Hello everyone, I am aware that there are already other posts on this topic in the forum, but they have neither helped me nor would they do any good.
But let’s start from the beginning.
I am currently creating an experience where a cube as a player (contains humanoid - see image) jumps around in a simple world. This is similar to the mobile phone game Crossy Road. My goal is for the cube to recognise objects such as trees or stones so that when a button is pressed, the cube stops jumping. The cube moves 5 studs in each direction, because the world (imagination please) consists of a 5x5 grid, where the cube and other objects should be in the centre.
The image shows the sensors (invisible red blocks in each direction of the white block), which should actually be triggered by the Touched function if there is an obstacle in this block. These red blocks also move with Motor6D, as the white block is equipped with a Humanoid and HumanoidRootPart. The HumanoidRootPart (main object) is invisible and is moved by TweenService and all parts are connected by Motor6D, where on the other hand the white block (name: character) is triggered by a correct animation.
I am aware from many other posts that the Touched function is disabled in Tween, but I have no idea how to effectively replace the Touch Event. I had read from other people that you could use RayCast, AsignPosition, RootWorld etc., but I could hardly find anything suitable on the Internet.
if key == "W" and not values.front_touched.Value then
debounce = true
local tween = TweenService:Create(primary.PrimaryPart,tween_info,{Position = Vector3.new(primary.PrimaryPart.Position.X,primary.PrimaryPart.Position.Y,primary.PrimaryPart.Position.Z + 5)})
tween:Play()
jump_sound:Play()
tween.Completed:Wait()
debounce = false
end
Here is the code where for the HumanoidRootPart (is the PrimaryPart of the model) the TweenService is executed when a button is pressed. This should move the white block by 5 studs.