|
| 15 May 2017 06:23 PM |
It works PERFECTLY, but only in Studio and not in-game. I was told I needed to use a remote event, and I've spent like 4 hours on youtube and the wiki trying to understand them. Then recently I've been told that since it's all on client side, I don't have to use a remote event? I'm really confused and in over my head since I've only been scripting for about 2 weeks now.
So this is what the scripts do, I got them working finally. Basically, when a player touches a brick, a sound from StarterGui plays, and when the player stops touching the brick, the sound stops playing.
These are the two scripts I have in the brick which triggers the sound when touched:
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then game.Players[hit.Parent.Name].PlayerGui.Sound2:Stop() game.Players[hit.Parent.Name].PlayerGui.Sound1.Volume = 1 game.Players[hit.Parent.Name].PlayerGui.Sound1:Play() print('test') script.Disabled = true script.Parent.Off.Disabled = false end end) ---------------------- script.Parent.TouchEnded:Connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then game.Players[hit.Parent.Name].PlayerGui.Sound1.Volume = 0 script.Disabled = true script.Parent.On.Disabled = false end end) ---------------------- Those above scripts work perfectly, but only in Studio. I just need them fixed so that they will play in-game for individual players, since this is a multiplayer game with different levels which each have their own song.
If you're NBC, I'll buy your t-shirt for your group to get you funds, or if you don't have a group, I can give you 350 funds.
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:31 PM |
| One Script to Rule them All: script.Parent.Touched:connect(function(hit) local plr = game.Players:FindFirstChild(hit.Parent.Name) or game.Players:FindFirstChild(hit.Parent.Parent.Name) if plr then local s = Instance.new("Sound") s.Name = "Music" s.SoundId = "rbxassetid://" s.Volume = ### ####### # # ######## = true s.archivable = false if plr:findFirstChild("Music") ~= nil then if plr:findFirstChild("Music").SoundId ~= s.SoundId then plr.Music:remove() s.Parent = plr s:play() end end if plr:findFirstChild("Music") == nil then s.Parent = plr s:play() end end end) |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:32 PM |
| let me try again since ROBLOX HAS TO FORMAT EVERYTHING script.Parent.Touched:connect(function(hit) local plr = game.Players:FindFirstChild(hit.Parent.Name) or game.Players:FindFirstChild(hit.Parent.Parent.Name) if plr then local s = Instance.new("Sound") s.Name = "Music" s.SoundId = "rbxassetid://143454738" s.Volume = ### ####### # # ######## = true s.archivable = false if plr:findFirstChild("Music") ~= nil then if plr:findFirstChild("Music").SoundId ~= s.SoundId then plr.Music:remove() s.Parent = plr s:play() end end if plr:findFirstChild("Music") == nil then s.Parent = plr s:play() end end end) |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:32 PM |
| okay sorry man, roblox is a #### but if you can figure out the format of that script then itll work -_- its the one i use. |
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
|
| 15 May 2017 06:36 PM |
Server cant access player gui
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:37 PM |
| @llaser I told him that already but he decided to make another thread |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:39 PM |
@graveyard Another guy in this forum said today that if I use a localscript in my starterGui, I don't have to use a remote event?
It's possible he's wrong, I'm just really confused right now I spent like another hour after you finished helping me trying to figure out how to make this all work and I couldn't
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:41 PM |
there is NO USE IN USING A REMOTE EVENT since all ur doing is going to AFFECT THE CLIENT ONLY
using a remote event for this is really stupid because there is literally no need to manually replicate something that only happens on the client |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:43 PM |
^
I have two people telling me two different things and I'm really confused I've only been scripting for like 2 weeks now, lol
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:44 PM |
remote functions and events should ONLY be used when u r sending data from client to server and server to client
using them here just makes it laggy and its completely stupid since ur only doing something to change on the client that requires no data whatsoever from the server as u can connect locally |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:45 PM |
| thats like saying u want to play a song when u press a button on the gui but u want the server to tell them when the button was pressed for no reason at all |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:51 PM |
got it so going back to what you told me earlier, how can I make this work in-game as opposed to it only working in studio?
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 06:54 PM |
| Just use a localScript. LocalScripts only do the code on the client side. I think it will only play the sound for the localplayer. You may have to enable filtering enabled for it to work. Just go to workspace, it is a property of it. I joined your group. Just give me a group payout, should work. Have a nice day! |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 07:00 PM |
I changed both scripts to a localscript inside the brick, and now it doesn't work
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 07:02 PM |
learn how to code and it wouldnt be hard at all its a very simple concept to grasp just use the event to turn the sound on and off the remotes are useless |
|
|
| Report Abuse |
|
|
|
| 15 May 2017 07:06 PM |
that's why I've spent over 6 hours writing this script, I'm trying my hardest to learn and getting conflicted answers and help I'm frustrated and really wanting to learn, and I feel like seeing a working copy at this point is going to be alot more useful for me to learn from then writing 10 - 15 more fail scripts
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 07:08 PM |
mine already is a working copy but u dont understand what variables are the path represents the path to the object u step on and there needs to be a sound named Sound1 to play and stop .-. |
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
|
| 15 May 2017 07:13 PM |
This Probably works i have no idea
--Reg Script local event = game.ReplicatedStorage.RemoteEvent
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) event:FireClient(plr,"Start") end end)
script.Parent.TouchEnded:Connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) event:FireClient(plr,"End") end end)
--Local local plr = game.Players.LocalPlayer local event = game.ReplicatedStorage.RemoteEvent
event.OnClientEvent:connect(function(action) if action=="Start" then plr.PlayerGui.Sound2:Stop() plr.PlayerGui.Sound1.Volume = 1 plr.PlayerGui.Sound1:Play() print('test') elseif action=="End" then plr.PlayerGui.Sound1.Volume = 0
end end)
|
|
|
| Report Abuse |
|
|
|
| 15 May 2017 07:17 PM |
| stop telling them to use events they are useless here |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2017 07:19 PM |
This might work:
--localScript
local sound = game.Workspace.PUTSOUNDHERE local brick = game.WorkSpace.PUTBRICKHERE
brick.Touched:connect(function() sound:Play() end
You don't actually need the humanoid checker. This fires whenever a player touches the brick.
|
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
| |
|
Narqwhal
|
  |
| Joined: 24 Apr 2011 |
| Total Posts: 301 |
|
|
| 15 May 2017 07:21 PM |
@llaser If you do not need to modify something for the whole server, yes, they are useless.
scripters.cf |
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
|
| 15 May 2017 07:22 PM |
Did You Disregard What I Just Said
|
|
|
| Report Abuse |
|
|
Narqwhal
|
  |
| Joined: 24 Apr 2011 |
| Total Posts: 301 |
|
|
| 15 May 2017 07:23 PM |
Yes, Because You Should Not Type Like This or give false information.
scripters.cf |
|
|
| Report Abuse |
|
|