FuzzyEq
(FuzzyEq)
March 23, 2021, 1:09am
#1
I want to play a sound from a normal script but I want to appear on a client only im trying to fire an event to fix it these are the scripts:
~LOCAL SCRIPT
game.ReplicatedStorage.Error.OnClientEvent:Connect(function()
script.Parent.Error:Play()
print("Fired")
end)
~NORMAL SCRIPT
game.ReplicatedStorage.Error:FireClient()
1 Like
xZylter
(xZylter)
March 23, 2021, 1:11am
#2
game.ReplicatedStorage.Error:FireClient([Player Instance])
You need to provide this function with a player who should receive this. Remove the square brackets
FuzzyEq
(FuzzyEq)
March 23, 2021, 1:12am
#3
Oh ok ill try that and put this as a solution if it works thank you
FuzzyEq
(FuzzyEq)
March 23, 2021, 1:14am
#4
what is a player instance is it like plr in brackets?
A Player Instance
is simply just the Player
object, or game.Players["4HM4DJ']
if that clarifies a bit more
You’d need to find some way to get the Player
inside a server script, which is the thing here
You have several different Events & functions that you can use that could help you get it, but it depends on when the Event is fired
FuzzyEq
(FuzzyEq)
March 23, 2021, 1:18am
#6
can i use when the player joins the game? i tried putting plr but it still didnt work?
It should look something like this:
game.Players.PlayerAdded:Connect(function(Player)
wait(10)
game.ReplicatedStorage.Error:FireClient(Player)
end)
FuzzyEq
(FuzzyEq)
March 23, 2021, 1:22am
#8
Yeah thats what i did… this is the normal script (a part of it)
Does the LocalScript
print anything when it’s fired?
FuzzyEq
(FuzzyEq)
March 23, 2021, 1:32am
#10
Nope but i get an error " 22:31:44.898 Argument 1 missing or nil - Server - "
Try just removing the PlayerAdded
event, I think it’s defined as nil
due to there being 2 functions tightening it
script.Parent.MainMesh.ClickDetector.MouseClick:Connect(function(Player)
local PlayerBasketCapacity = game.ServerStorage.Baskets.StarterBasket.MaxCapacity
if plr.PlayerDataFolder.PlayerFoodAmount.Value >= PlayerBaskerCapacity.Value then
print("Bucket Capacity is full!")
plr.PlayerDataFolder.CanCollect.Value = false
game.ReplicatedStorage.Error:FireClient(Player)
end
end)