Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can't my tool work?[Solved]

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

✓ Accepted answer

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.

4 comments

0

I already have the tool and the unsheath audio. I said it was part of the script.

0

Wow, a person with 4 reputation beat a person with 10.

0

Also, the audio wasn't in the tool. I did Instance.new("Sound", Player)

0

Thought so. Glad I could help.

This discussion is preserved as it was. New answers, comments, and votes are closed.