Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come the model wont move?

Asked by 9 years ago

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)

1 answer

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
9 years ago

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. :)

Ad

Answer this question