I've added in my game a script. When we press the correct key it is supposed to create a beam in front of you that deals damage but there is a problem : I dont know how to change the size of only 1 surface of a part , without using Resize() caus it doesnt work with .Touched event. I tried using Vector3 but im not totally at ease with it. I found how to increase the size properly but the size does not increase in front. For example, if i chose to increase the Front size with Vector3, it also increase Back size. I though about modifying the position but i dont know how to do it.
So, i know that wasnt very simple to understand so, this is what is would like : When it grow (by the loop in the code down below) i would like the beam to always be at the correct position (the beginning just at my wand's position and the end at where i aimed the mouse)
Here is the code :
game:GetService("ReplicatedStorage").Tool.OnServerEvent:connect(function(player, position) -- the position variable is the position where the player clicked with the mouse local tool = game.Workspace[player.Name].WandTool local beam = script.Parent beam.CFrame = CFrame.new(tool.Emitter.CFrame.p, position) for i = 1,20 do beam.Size = beam.Size + Vector3.new(0,0,1) --This increase the size of both side (Front and Back, Top and Bottom, etc.... it depends of what side i chose to modify) beam.Position = beam.Position + Vector3.new(0,0,1) -- It doesnt do the right thing wait(0.1) end end)
Make a mental image of what happens. A direct resize changes two sides equally; each side extends by half the resize. To get the opposite side to its original position, you should use half the resize again, not the whole.
so this is probably all you need to change ye?
beam.Position = beam.Position + Vector3.new(0,0,0.5)