Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

3 comments

0

simple answer: local scripts will not work in the workspace.

0

where do i put it then?

0

in the starter scripts

1 answer

✓ Accepted answer

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.

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.