Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make things only show up on one client????

Asked by 3 years ago
Edited 3 years ago

Through a local script, I turn particles on and off by enabling them. I also have filtering enabled on. The problem is, no matter what I do they always show up on all the clients. I tried cloning the particles through the local script and stuff, but it just never works. The script is in the starter character and I tried moving it to other places to see if it would work. I tried having the particles cloned from replicated first and replicated storage. I also tried testing in the studio and in just a normal Roblox server. Am I just dumb and not realizing that I have to do something else? The particles don't show up on the server, but on every single client.

All my script does is create a sound, play a sound, turn on some particles, wait for the sound to finish, then destroy the sound and then disable all the particles. I'll put some of that script if it helps but I really don't understand what is going on!

I really need help I've been looking up stuff on the internet for a couple of days now!

local replicatedfirst = game:WaitForChild('ReplicatedFirst')
local stuff = game.Workspace.TutorialStuff
local confetti1 = stuff.Confetti1
local confetti2 = stuff.Confetti2
local part = stuff["Confetti Trigger"]
local debounce = false
local player = game.Players.LocalPlayer

part.Touched:Connect(function(hit)
    if not hit.Parent:FindFirstChild("Humanoid") then return end
    if hit.Parent.Humanoid.Health == 0 then return end
    if debounce == true then return end
    debounce = true

    local particle1 = confetti1:GetChildren('ParticleEmitter')
    local particle2 = confetti2:GetChildren('ParticleEmitter')
    local sound = Instance.new('Sound')
    sound.Parent = hit.Parent
    sound.SoundId = 'rbxassetid://2762666255'
    sound.Name = 'PartySirens'
    sound.Volume = 0.5

    sound:Play()

    for i = 1, #particle1 and #particle2 do
        particle1[i].Enabled = true
        particle2[i].Enabled = true
    end
    repeat wait() until sound.TimePosition >= 6.3

    for i = 1, #particle1 and #particle2 do
        particle1[i].Enabled = false
        particle2[i].Enabled = false
    end
    sound:Destroy()
    debounce = false
end)

stuff = where everything is located in workspace

confetti1/2 = part that contains particles

0
wdym they show up on every client but not on the server, doesn't that mean it's on the server otherwise? sean_thecoolman 189 — 3y
0
Well... I tested it in studio and it show up on all the client's windows, but when you go to the server's window you can't see anything. ASimpleGalaxy 36 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

One answer: Use RemoteEvents. RemoteEvents can be used to send information from client(s) to server or server to client(s).

--Client script (LocalScript)
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(player)
       --particle code here, yada yada, etc etc.
end)

Learn about RemoteEvents here: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

0
Soo are you saying I should have the trigger activated on a server script and then use a remote event to do stuff on a local script? ASimpleGalaxy 36 — 3y
0
Oh thank you! It worked. But can you explain as to why when I have it only in a local script, it goes to all the other clients? Does it have something to do with the touched event in it 'cause I have not idea. ASimpleGalaxy 36 — 3y
0
Localscripts usually aren’t supposed to be used in workspaces and such. They run lua code on a client. They can be used to access objects only the client faces. RemoteEvents, however, have the power to send information between clients and servers. Sorry if that is a bad explanation. nekosiwifi 398 — 3y
0
Soo why was it going to all the other clients then? That's the thing that is confusing me so much. I use remote events for a lot of things and understand how local scripts aren't supposed to be in the workspace and stuff. Ahh I'm so confused are local scripts only supposed to run on one client and only one or?? ASimpleGalaxy 36 — 3y
Ad

Answer this question