Hi, I started scripting not to long ago and I need help with this idea I have. My problem is that I have no idea where to start or how to do it. What I want to do is have a block but when you touch it it flings itself in the opposite direction. Again i am very new with scripting so I have no idea where to start. Your help is greatly appreciated! ![]()
Using CFrame.LookAt, and CFrame.LookVector, we can do this.
script.Parent.Touched:Connect(function(Hit) -- Set up an event for when its touched
if game.Players:GetPlayerFromCharacter(Hit.Parent) then -- check if the hit part is part of a player
local FlingVelocity = 100 -- set velocity of fling
local newCFrame = CFrame.lookAt(script.Parent.Position,Hit.Position) --Generate a CFrame based on the hit part and the fling part's positions
local LookVector = newCFrame.LookVector --Get the LookVector of the generated CFrame
script.Parent.Velocity = Vector3.new(LookVector.X,LookVector.Y,LookVector.Z) * -FlingVelocity -- Fling the object
end
end)
The baseplate acts like a conveyor when I touch it, dunno how to fix it.
What do you mean by the baseplate acts like a conveyor?
The player moves not the part when I touch it
Is the part anchored?
Thats what anchored parts do when they have velocity
Wow never mind it worked! I accidentally had it anchored! Thanks for all your help!