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

Why can't my tool work?[Solved]

Asked by 10 years ago

This is just part of my script.

function onEquipped()
    UnsheathSound:Play()
    game.Players:FindFirstChild(Tool.Parent.Name).CameraMode = "LockFirstPerson"
end

function onUnequipped()
    UnsheathSound:Pause()
game.Players:FindFirstChild(Tool.Parent.Name).CameraMode = "Classic"
end

This is what I need it to do...

Play Sound LockFirstPersonCameraType

Pause Sound Classic CameraType

The script

Plays Sound LockFirstPerson

It doesn't

Pause Sound Change Camera back to Classic

I think it has to do with the fact that the tool unequipped. I'm making a crowbar from Half Life with the 2 types of Barrels. The Unsheath is the VALVe logo song.

1 answer

Log in to vote
0
Answered by
DevChris 235 Moderation Voter
10 years ago

Okay, here's my best shot. If you're using a Script, use a LocalScript. Copy all the code, delete the Script, and put it in a LocalScript.

Put this code in the LocalScript:

local tool = script.Parent --Put the LocalScript in the Tool
local player = game.Players.LocalPlayer
local UnsheathSound = tool.Handle.SoundName --Make sure it has a SoundId and is in the Handle!

function onEquipped()
    UnsheathSound:Play()
    player.CameraMode = "LockFirstPerson"
end
function onUnequipped()
    UnsheathSound:Pause()
    player.CameraMode = "Classic"
end

I hope this works.

0
I already have the tool and the unsheath audio. I said it was part of the script. EzraNehemiah_TF2 3552 — 10y
0
Wow, a person with 4 reputation beat a person with 10. EzraNehemiah_TF2 3552 — 10y
0
Also, the audio wasn't in the tool. I did Instance.new("Sound", Player) EzraNehemiah_TF2 3552 — 10y
0
Thought so. Glad I could help. DevChris 235 — 10y
Ad

Answer this question