Ad
Log in to vote
1

Car Horn Doesn't Work How Will I fix it??

Asked by 2 months ago
Edited 2 months ago

[REPOST] Trying to make a carhorn system when a player clicks the horn button that the car he is in will honk. I tried this script only issue with it is if you got 2 or more of the same car spawned only one works and its the wrong car honking most of the time.

local horn = script.Parent.Parent.Parent.HornPart.Horn1 — Check the Parents

script.Parent.MouseButton1Down:Connect(function()

horn:Play()

end)

So i tried modifying the script to work with the string value named Owner. When a Player spawns a car the Owner value chages to their username. The value is placed in the car model. There is a horn part placed in the car body with a script and horn audio. BTW Horn1 is the audio name. And HornPart is the part with the script and sound. Owner I believe is a string value. Modifications:

local Owner = (player.Name)

local horn = game.Workspace.HondaCivic.Owner

script.Parent.Parent.Parent.Parent.HondaCivic.Body.HornPart.Horn1 = horn:Play()

script.Parent.MouseButton1Down:Connect(function()

    horn:Play()

end)

It doesn't work at all :( BTW HondaCivic is the car's name.

New modifications

local horn = game.Workspace.HondaCivic.Owner

script.Parent.Parent.Parent.Parent.Owner.Value = (player.Name)

script.Parent.Parent.Parent.Parent.HondaCivic.Body.HornPart.Horn1 = horn:Play()

script.Parent.MouseButton1Down:Connect(function()

    horn:Play()

end)
0
Do you use discord? if so, can you send me a picture of the heiarchy? Kingu_Criminal 170 — 2mo
0
Hi, I sadly don't use discord. If you want I can make a Google drive with the pictures and send the link? Also what are you wanting pictures of? blue_bunny0fficl 64 — 2mo

2 answers

Log in to vote
1
Answered by 2 months ago

Are you new to scripting? You do know that defining variables goes variable on the left, value on the right?

variable = value

I doubt your local horn object is a sound, considering how you reference it... so no play method will work

0
I am Very new to scripting I started a month ago. And yes horn is a sound in the car's body in a part named Carhorn. And I did not know variables can go left value on the right. I updated my post to show you my new script is still doesn't work :( blue_bunny0fficl 64 — 2mo
0
Also for some reason player keeps getting underlined in blue blue_bunny0fficl 64 — 2mo
0
Hi, I sadly don't use discord. If you want I can make a Google drive with the pictures and send the link? Also what are you wanting pictures of? blue_bunny0fficl 64 — 1mo
Ad
Log in to vote
0
Answered by 1 month ago

Nevermind

Answer this question