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

How would I make this script work in a localscript?

Asked by 6 years ago
Edited 6 years ago

this script launches a player in the air and plays a sound both at the same time when they touch the brick. the launching part works but the sound playing doesn't. I want the sound to be played locally so i only want the person that touches the brick to hear the sound. And im pretty sure to do that you need to have the script a localscript (because localscripts only run things like localplayer and playergui . and idk if normal scripts can run localplayer and playergui) this is tricky to fix because when i go into studio the script works fine and both work. but when i actually play the game only the launching part works, but when i use F9 and have a look it says localplayer is a nil value which makes me believe this script that i have needs to be a localscript.

Heres the script

(jumper is the name of the sound i have)

also keep in mind this is in a NORMAL script and not a LOCALSCRIPT. so all im wondering is how would i get this script to work in a localscript

function onTouched(part)
    if part.Parent ~= nil then
        local h = part.Parent:findFirstChild("Humanoid")
            if h~=nil then          
h.Parent.Torso.Velocity=Vector3.new(0,210,0)
game.Players.LocalPlayer.PlayerGui.jumper:Play()

            end         
    end
end

script.Parent.Touched:connect(onTouched)












0
Yes, since game.Players.LocalPlayer can only be obtain in LocalScript. thesit123 509 — 6y
0
yes but when i put it in a localscript it doesnt work and nothing shows up in the output supamaster888 28 — 6y

Answer this question