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

Why does it clone the StringValue into all players?

So i want players to be able to claim a brick once when they click it. Currently instead of cloning a string value to the player that clicked the brick it gives clones to all players

--script

local ReplicatedStorage = game.ReplicatedStorage
local event = ReplicatedStorage.RemotEvent
bricks = game.Workspace.bricks



event.OnServerEvent:Connect(function(plr)
	for i,clickedbrick in pairs(bricks:GetChildren()) do
	for i,detector in pairs(clickedbrick:GetChildren()) do
	detector.MouseClick:Connect(function()
		
		if plr.questFolder:FindFirstChild(clickedbrick.Name) then
		print("Already claimed")
	else
		local cb = Instance.new("StringValue")
		cb.Parent = plr.questFolder
		cb.Value = clickedbrick.Name
		cb.Name = clickedbrick.Name
		
				end	
			end)
		end
	end
end)

--localscript

local ReplicatedStorage = game.ReplicatedStorage
local event = ReplicatedStorage.RemotEvent

game.Workspace.Baseplate.ClickDetector.MouseClick:Connect(function()
	event:FireServer()	
end)

1 answer

I don't know why, you have it fire when you click another part...Anyways, it seems like that was your issue.

Try this, in your local script:


local ReplicatedStorage = game.ReplicatedStorage
local event = ReplicatedStorage.RemotEvent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

mouse.Button1Down:Connect(function()
    event:FireServer(plr)  
end)

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