I concocted this simple script to make a player launch up & back whenever they touch the tool's handle and although the damage part works the character wont move, any suggestions?
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then C = h.Parent:GetPrimaryPartCFrame() C = C*CFrame.new(0, 10, 10) print(C) h.Health = h.Health -14 wait(1) end end
script.Parent.Touched:connect(onTouched)
Firstly, try out the code block feature so that your script is easier to read.
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then C = h.Parent:GetPrimaryPartCFrame() C.CFrame = C.CFrame * CFrame.new(0, 10, 10) print(C.Name) h.Health = h.Health -14 wait(1) end end script.Parent.Touched:connect(onTouched)
The above script is fixed. To move the part, you multiply its CFrame by another CFrame, not the actual part by another CFrame. To do this, you would put C.CFrame * CFrame.new(0, 10, 0)
(Line 5) intead of C * CFrame.new(0, 10, 0)
. Also, I'm assuming you want it to print the part's name, so you would print print(C.Name)
. Also, the wait(1) at the end is not necessary unless this is not the full script. I didn't remove it because of that scenario.
Hope I helped. :)