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

[SOLVED] How do I make this command only do the action to one player?

Asked by 5 years ago
Edited 5 years ago

So basically what this code does is when the player says !nosnow it turns off the snow. How would I make it so !nosnow and !snow only turn the snow on/off for the player who said it and not the entire server?

function onChatted(msg, speaker)
    local source = string.lower(speaker.Name)
    msg = string.lower(msg)
    if msg == "!nosnow" then
        game.Workspace.Snow.Snow1.ParticleEmitter.Enabled = false
        game.Workspace.Snow.Snow2.ParticleEmitter.Enabled = false
    elseif msg == "!snow" then
        game.Workspace.Snow.Snow1.ParticleEmitter.Enabled = true
        game.Workspace.Snow.Snow2.ParticleEmitter.Enabled = true
    end
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg) onChatted(msg, player) end)
end)        
0
use remote events and fire it with FireClient I believe TheGreenSuperman 85 — 5y
0
So when it's fired, would I make it so a local script picks up the event? TypicallyPacific 61 — 5y
0
yes User#23365 30 — 5y
0
I did it but it's not working. TypicallyPacific 61 — 5y

Answer this question