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

Why is this script showing for more than just the client who activated it?

I did this script in studio, it's supposed to only make the person who activated it be able to see what's behind the blocker

local PictureBlocker = game.Workspace.PictureBlocker
local ActivPart = game.Workspace.ActivationBlock
ActivPart.Touched:Connect(function(hit)
		if PictureBlocker.Transparency == 0 then
	PictureBlocker.Transparency = 1 else
	PictureBlocker.Transparency = 0
end
end)

But it goes off and sometimes it does not work for the main player, and sometimes it goes to both players, if that made sense, it is in a LocalScript so I don't know what I'm doing wrong.

1 answer

This is activated when literally anyone, or anything touches the part. Put some if some if statements to make sure that 1. A player has touched the part, and 2. That it is the current player. Here's a code example to get how you could implement this into your code

part = script.Parent

part.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
	if hum ~= nil then
		local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
		--This script gets the player that has hit the block
	end
end)

I'm sure you can figure it out yourself, that way it also feels better rather than getting all the code without doing any work.

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