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

Script for swiming in water?

Asked by 9 years ago

I made a code but it's not working. There's a place in the studio which has the cancollide property false.I added this script in but it's not working.How can I make it work?It works in Studio but not in Player

function onTouched(part)
    if part.Parent ~= nil then
        local h = part.Parent:findFirstChild("Humanoid")
            if h~=nil then
if  (h.Parent.Torso.Velocity.y < 44) then
h.Parent.Torso.Velocity=Vector3.new(0,h.Parent.Torso.Velocity.y+25,0)
end

            end         
    end
end

script.Parent.Touched:connect(onTouched)
0
It should work fine if I read it, but what is it doing - or even: what is it not doing? Also, check the output for any error messages. I just came back from a very long break, so my knowledge might be very rusty. TheMyrco 375 — 9y
0
I edited the question brokenrares 48 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

What errors do you have?

You need to do some basic debugging before coming here.

Change it to this:

function onTouched(part)
    if part.Parent ~= nil then
        local h = part.Parent:findFirstChild("Humanoid")
            if h~=nil then
print('Humanoid is not nil')
if  (h.Parent.Torso.Velocity.y < 44) then
print('Humanoid Torso velocity is below 44!')
h.Parent.Torso.Velocity=Vector3.new(0,h.Parent.Torso.Velocity.y+25,0)
print('Changed velocity!')
end

            end         
    end
end

script.Parent.Touched:connect(onTouched)

Tell me if it says: 'Humanoid is not nil', 'Humanoid Torso velocity is below 44!', and Changed velocity!

Press F9 while in game, see if there are any errors, and if so write them here. If no errors tell me if it says all of the above statements

0
In studio it works, but when I try and see if it works in Roblox Player iI just fall off the map. This is a script not a local script(if that metters) brokenrares 48 — 9y
0
Press F9 In game for the console, click 'Server Scripts' (or similar) and see any errors from your script. Then post them here. unix_system 55 — 9y
Ad

Answer this question