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

Snow is not disabling when the command is said, why?

Asked by 5 years ago

So I've created a script so when a player says !nosnow it disables snow for them only and not anyone else. When I test it I get no errors and nothing happens. What did I do wrong?

Here's what is in my server script (which is in serverscriptservice):

local  rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("NoSnow")
local event2 = rs:WaitForChild("Snow")

function onChatted(msg, speaker)
    local source = string.lower(speaker.Name)
    msg = string.lower(msg)
    if msg == "!nosnow" then
        event:FireClient(speaker)
    elseif msg == "!snow" then
        event2:FireClient(speaker)
    end
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg) onChatted(msg, player) end)
end)        

Here's what is in my local script (which is in workspace):

local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("NoSnow")

local function onEventFired()
    game.Workspace.Snow.Snow1.ParticleEmitter.Enabled = false
    game.Workspace.Snow.Snow2.ParticleEmitter.Enabled = false
end

event.OnClientEvent:Connect(onEventFired)
0
simple answer: local scripts will not work in the workspace. SteamG00B 1633 — 5y
0
where do i put it then? TypicallyPacific 61 — 5y
0
in the starter scripts SteamG00B 1633 — 5y

1 answer

Log in to vote
0
Answered by
ee0w 458 Moderation Voter
5 years ago
Edited 5 years ago

You forgot the second event in your LocalScript, silly!

local rs = game:GetService("ReplicatedStorage")
local noSnow = rs.NoSnow
local snow = rs.Snow

local emitter1 = workspace.Snow.Snow1.ParticleEmitter
local emitter2 = workspace.Snow.Snow2.ParticleEmitter

local function setSnowEnabled(status)
    emitter1.Enabled = status
    emitter2.Enabled = status
end

snow.OnClientEvent:Connect(function()
    setSnowEnabled(true)
end)
noSnow.OnClientEvent:Connect(function()
    setSnowEnabled(false)
end)

Also, you should put your LocalScript inside StarterPlayerScripts so that it actually runs.

0
I know I didn't add it yet but thanks anyways. I was trying to make sure the first one worked at least. Steam helped me by telling me not to put it in the workspace. I remembered I had to put it in StarterCharacterScripts. TypicallyPacific 61 — 5y
Ad

Answer this question