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

How can I make script that I can make a sound when I press keybind while I am on driverseat?

Asked by 3 years ago

I tried to make a script that can make a sound when I press keybind while I am on driverseat but I want to hear sound everyone who is near me.

I tried almost every way but it Didnt works.

Here is main script:

function powers()
    if script.Parent.Occupant~= nil then
        local Anyone = script.Parent.Occupant
        local player = game.Players:GetPlayerFromCharacter(Anyone.Parent)
        if player ~= nil then
            if Anyone.Parent:findFirstChild("LocalScriptHorn") == nil then
            local Load = script.LocalScriptHorn:Clone()
            Load.Parent = player.Character
            Load.Disabled = false
            Load.CarValue.Value = script.Parent.Parent
            end
        end
    end
end
script.Parent.Changed:connect(powers)

Localscript inside main script:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.Seated:Connect(function(isSeated, seat)
    if isSeated then
        if seat then    
           local Player = game.Players.LocalPlayer
           local mouse = Player:GetMouse()
           mouse.KeyDown:connect(function(key)
           if key == "e" then
              print("Down E")
              script.CarValue.Value.Horn.Sound:Play()
              script.CarValue.Value.Effect.ParticleEmitter.Enabled = true
           end
           end)
           mouse.KeyUp:connect(function(key)
           if key == "e" then
              print("Up E")
              script.CarValue.Value.Horn.Sound:Stop()
              script.CarValue.Value.Effect.ParticleEmitter.Enabled = false
           end
           end)

        end
    else
        script:remove()
    end
end)

How it looks: https://imgur.com/BpjKlTO

0
local script wont run locally inside a script, put it in a place that server scripts dont usually go (replicatedFirst playergui playerscripts etc) kepiblop 124 — 3y
0
I dont understand, can you please write it to me easier? I am not a professional scripter at all. testmiskobay 0 — 3y

Answer this question