I have a small problem, I hope theres a quick fix for that.
This LocalScript is in StarterPlayerScripts:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local HumanoidRootPart = Character:waitForChild("HumanoidRootPart")
local Beam = script:WaitForChild("Beam"):Clone()
local function CreateBeam(Beam, Attachment0, part)
local Attachment1 = part:FindFirstChild("Attachment")
if Attachment1 then
Beam.Attachment0 =Attachment1
Beam.Attachment1 =Attachment0
end
end
local ArrowEventSound = script:WaitForChild("FirstTask")--this line
game.ReplicatedStorage.ArrowEvent.OnClientEvent:Connect(function(part, Value)
if Value == true then
local Attachment0 = HumanoidRootPart:FindFirstChild("RootRigAttachment")
CreateBeam(Beam, Attachment0, part)
Beam.Parent = Character
elseif Value == false and Player.Backpack:FindFirstChild("Wheelbarrow") then
Beam:Remove()
elseif Value == false then
ArrowEventSound:Play()
Beam:Remove()
end
end)
You see, the sound should play locally. But it doesn’t. Every player can hear the sound.
How do I fix that?
local Tool = script.Parent
local Player1 = Tool.Parent
local Player = game.Players:GetPlayerFromCharacter(Player1)
--warn(20)
--warn("abcdef "..Player.Team.Name)
local ArrowEvent = game.ReplicatedStorage:WaitForChild("ArrowEvent")
local Team = Player.Team.Name
local ArrowbeamEnd = workspace["Zednov's Tycoon Kit"].Tycoons[tostring(Team)].PurchasedObjects.Wheelbarrow.End.Part1 --here add a reference to wherevever Wheelbarrow.End.Part1 is
Tool.Equipped:Connect(function()
ArrowEvent:FireClient(Player,ArrowbeamEnd,true)
end)
Tool.Unequipped:Connect(function()
ArrowEvent:FireClient(Player,ArrowbeamEnd,false)
end)
Can I see the tool object, with it’s children in the explorer? This will help me further debug your issue as I think I know what is happening here…
You shouldn’t need to use a serverscript to be listening for an equipped event. It’s actually documented that these events should be observed on the client. As far as the sound being placed into workspace i don’t believe this will have much of an impact. Could be wrong though…
To put it simply, just add the equipped and unequipped events into the localscript that already exists, and run your arrow event logic without having the remoteevent handling…
Couldn’t you just call PlayLocalSound() from that LocalScript? Sound replication is weird when it comes to instances such as these, so I’d recommend placing the Sound inside SoundService/workspace or somewhere alone those lines