|
| 16 Jun 2016 12:39 PM |
i have filteringenabled on, so i dont think I can just reference it
for arguments sake, i want it to be so where i touch a brick, it plays a noise from the hud/locally
here's what i have, but because of filteringenabled, it doesn't work (i think)
local db = false function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h ~= nil and db == false then db = true local playerName = part.Parent.Name h.Health = h.Health - 15 game.Players[playerName].PlayerGui.advancedGui.hudSounds.rads:Play() wait(1) db = false wait(3) game.Players[playerName].PlayerGui.advancedGui.hudSounds.rads:Stop() end end script.Parent.Touched:connect(onTouched)
i tried fooling around with firing a sound remoteevent, but I don't really know how to do it |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 12:42 PM |
you're gonna want to use remoteevents to make changes in playergui from a server script http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial use :FireClient() to communicate from server to local
mom wheres the spaghetti |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 12:43 PM |
alright, gonna give it a try
is there any unique way to set it up for a string? or is it just the same as an int, but use "string" where the type would be |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 12:44 PM |
wait nevermind, this tutorial has strings how did i miss this ty ty ty |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:06 PM |
despite the tutorial, i think i might be using it terribly wrong can anyone point me in the right direction?
--script local db=false function onTouched(hit) if hit.Parent:FindFirstChild('Humanoid')then do if (db == false) then db = true local playerName = hit.Parent.Name game.ReplicatedStorage.soundEvent:FireClient("kaboom") wait(.01) script.Parent:Destroy() end end end end script.Parent.Touched:connect(onTouched)
--localscript game.Players.LocalPlayer:WaitForChild("soundEvent").OnClientEvent:connect(function(player, string, soundType) script.Parent.advancedGui.hudSounds[soundType]:Play() end) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:07 PM |
>game.Players.LocalPlayer:WaitForChild("soundEvent").OnClientEvent:connect(function(player, string, soundType)
you have 2 variables you need, but you only gave one, which was for "string"
mom wheres the spaghetti |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:10 PM |
edit:
you need to include the player in the paramaters of :FireClient() use :GetPlayerFromCharacter() to get the player and then do :FireClient(PlayerInstance,sound)
mom wheres the spaghetti |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:11 PM |
got it? i think? game.ReplicatedStorage.soundEvent:FireClient(game.Players[playerName],"kaboom")
only thing is, i don't hear it but the brick itself does everything else with no error |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:12 PM |
| (we posted at exact same time, trying what you suggested) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:15 PM |
works exactly the same as how i did it but i still don't hear anything .-.
also i didnt know this existed: http://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerFromCharacter
its something i wish i knew about ages ago |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:19 PM |
---Server :FireClient(Player, soundName) ---Include player in parameters, along with other things ---Client .OnClientEvent:connect(function(soundName) ---You don't need to include the player in these parameters. [soundName]:Play() end)
mom wheres the spaghetti |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:20 PM |
doing some tinkering, i think its from the localscript side
game.Players.LocalPlayer:WaitForChild("soundEvent").OnClientEvent:connect(function(player, string, soundType) script.Parent.advancedGui.hudSounds[soundType]:Play() end)
no matter what i put in the function body, it runs without any error is it the way i'm trying to play the sound or? |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:20 PM |
| (oh snap, we're on the same brainwave, posted at same time again, checking) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:29 PM |
still can't get the darned thing to play i can literally put anything i want in the localscript, and it still 'works' but doesn't play the sound |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:31 PM |
i'm unsure of the problem but >MAYBE< it's because you're using :Play() in a localscript
mom wheres the spaghetti |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:33 PM |
perhaps but i have a print in the localscript, and it doesn't print
it's almost as if it never gets the event |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 16 Jun 2016 01:35 PM |
--server script
local re = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local part = script.Parent
part.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then re:FireClient(player) end end)
--local script
local gui = script.Parent local sound = gui.Sound
local re = game.ReplicatedStorage:WaitForChild("RemoteEvent")
re.OnClientEvent:connect(function() sound:Play() end)
|
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:35 PM |
got it >game.ReplicatedStorage:WaitForChild("soundEvent").OnClientEvent:connect(function(soundName)
it was a matter of where the remoteevent was placed whoopsie
thanks for the help man |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2016 01:37 PM |
(why do i always post at the same time as a reply) but yeah, i accidentally figured out what you posted just as you posted it thanks dude |
|
|
| Report Abuse |
|
|