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

How do I affect the lighting of only one player?

Hi, I am trying to make a tool in roblox that makes people blind. How do I make the tool affect only one player at a time.

I am aware of lighting but that affects the whole server.

Thanks for help

1 comment

0

Handle the code on the client.

2 answers

✓ Accepted answer

If your game has FilteringEnabled, then anything done in a LocalScript will only be visible to the player.

If you wanted to create a PointLight object when the player clicks with the tool, then you would do this in a LocalScript:

-- localscript

local tool = script.Parent
tool.Activated:Connect(function()
	local pointLight = Instance.new("PointLight")
	pointLight.Parent = workspace
end)

The above script will create a new PointLight object that can only be seen by the player who clicked.

I hope this helps :)

1 comment

0

thx a lot, this really helped!

Mess around with local. If you use "local" before a line of code, it will only affect the player who is having the script run on them, or just use a local script, but I advise the first one.

2 comments

0

I don't think you understand the usage of 'local'. That's used to define the scope of a variable to be within it's local environment, not to be applied only to the local player.

0

It honestly depends.

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