Why doesn't it work?

I’m trying to find out if the value is equal to the player id, but it doesn’t work?
Thanks to anyone who will help me
My script:

local Owner = target:FindFirstChild("Owner")
				if Owner.Value == plr.UserId then
				print("yes")
			target:Destroy()
3 Likes

we need a lot more context than this.

Unfortunately, this is really just that…
As an example, I’m trying to find out if “Owner” is equal to the player id. So I put the previous script but it doesn’t work.
I tried when I write my player id instead of plr.UserId, and it works. (Homewer, plr is correct)

thats the entire script? why would it work then??

ScriptContext? (Server/Local)?? Could you provide console outputs returned by the script? Please provide the entire script and screenshot of the targeted part (including its children)

Reminder: plr by default is not a variable.

There is some script before, but I put “prints”, the script stops at plr.UserId.
I correctly identified plr. Its a server script. No errors in console

a little more script:

	if target and target:FindFirstChild("Placeable") then
			print("placeable")
			
			if target:FindFirstChild("Owner") then
				print("Owning")
				
				local Owner = target:FindFirstChild("Owner")
				if Owner.Value == plr.UserId then
				print("yes")
			target:Destroy()

Le “print(owning)” apparait bien dans la console.

we cant do anything to fix this if you don’t show us the full code big dawg :skull:

just go into the script, press ctrl+a, ctrl+c and come here and press ctrl+v

ain’t that hard

1 Like

Hum… Its just long:
Server script:

local snap = 1


game.ReplicatedStorage:WaitForChild("PlaceBlockRE").OnServerEvent:Once(function(plr, blockType, target, targetSurface, removeOrPlace)

	
	if removeOrPlace == "placing" then
		
		
	
		local position
		
		if targetSurface == Enum.NormalId.Top then
			position = target.Position + Vector3.new(0, snap, 0)
				
		elseif targetSurface == Enum.NormalId.Bottom then
			position = target.Position - Vector3.new(0, snap, 0)
				
		elseif targetSurface == Enum.NormalId.Left then
			position = target.Position - Vector3.new(snap, 0, 0)
				
		elseif targetSurface == Enum.NormalId.Right then
			position = target.Position + Vector3.new(snap, 0, 0)
				
		elseif targetSurface == Enum.NormalId.Front then
			position = target.Position - Vector3.new(0, 0, snap)
				
		elseif targetSurface == Enum.NormalId.Back then
			position = target.Position + Vector3.new(0, 0, snap)
		end
		
			
		local blockInPos
			
		for i, d in pairs(workspace:GetDescendants()) do
				
			if d:IsA("BasePart") and d.Position == position then blockInPos = true end
		end
			
			
		if not blockInPos and position then
			
			local newBlock = blockType:Clone()
			
			local newblockchild = newBlock:GetChildren()
			
			
			
			for tablepos,instance in pairs(newblockchild) do
				
				instance.Anchored = true
				
				
				
				instance.SelectPart.Transparency = 0.5
				

				instance.Parent.Parent = workspace
				
				newBlock:MoveTo(position)
				
				plr.PlayerGui.BlockPicker.Cancel.Visible = true
				plr.PlayerGui.BlockPicker.Confirm.Visible = true
				
				local Owner = Instance.new("StringValue")
				Owner.Name = "Owner"
				Owner.Value = plr.UserId
				Owner.Parent = instance
				
				repeat wait() until
				plr.PlayerGui.BlockPicker.Confirm.MouseButton1Click:Once(function()
					
				game.ReplicatedStorage.PlaySoundRE:FireClient(plr)
				instance.SelectPart.Transparency = 1
				instance.SelectPart.CanTouch = false
				instance.SelectPart.CanCollide = false
				instance.SelectPart.CanQuery = false
				
				
					plr.PlayerGui.BlockPicker.Cancel.Visible = false
					plr.PlayerGui.BlockPicker.Confirm.Visible = false
					script.Disabled = true
					script.Disabled = false
				end)
					
				plr.PlayerGui.BlockPicker.Cancel.MouseButton1Click:Once(function()
					
					
					newBlock:Destroy()
						plr.PlayerGui.BlockPicker.Cancel.Visible = false
						plr.PlayerGui.BlockPicker.Confirm.Visible = false
					script.Disabled = true
					script.Disabled = false
					
				end)
			end
			--newBlock.Size = Vector3.new(snap, snap, snap)
			
		end
		
		
	elseif removeOrPlace == "removing" then
		
		if target and target:FindFirstChild("Placeable") then
			print("placeable")
			
			if target:FindFirstChild("Owner") then
				print("Owning")
				
				local Owner = target:FindFirstChild("Owner")
				if Owner.Value == plr.UserId then
				print("yes")
			target:Destroy()
			
			game.ReplicatedStorage.PlaySoundRE:FireClient(plr)
			script.Disabled = true
			script.Disabled = false
			
					else script.Disabled = true
						 script.Disabled = false
			end
			else script.Disabled = true
				script.Disabled = false
			end
		end
	end
end)

This script work with a local script (local script is total good)

But its not util, I know how far the script works.

just cause you know what it means doesn’t mean it cant have an error. It could be setting a variable incorrectly or something, we have no way to see what all the variables in this code mean.

any errors?

addtextaddtextaddtextaddtextaddtext

image

@nvthane sent me that, mark his as the solution.

to use an if or an else, you need “==” instead of “=”

I just noticed something else.

How in hell is it supposed to set itself as enabled if its disabled :skull:

3 Likes

Hmm, I know my variables are functional.
For example, if I put my player id in place of “plr.UserId”, it will work. By saying this you will think that plr is therefore wrong, but no because if I enter "print(plr.UserId) it will also work.
Owner is also good, because if I put “print(Owner)” it also gives me the desired value…
(Sorry for the mistakes, I’m French)

Edit:Hum, it’s the lua, the code can turn back on even if it’s disabled

the script,
doesnt run,
when its disabled.

Try it yourself lol

script.Disabled = true
script.Disabled = false

it work

you should probably take your own advice, buddy.


print(Owner.Value)
print(plr.UserId)
	if Owner.Value == plr.UserId then

I tried this, the “prints” return the same value in the console

loll,

try this script : ) :

print("Hello world!")
script.Disabled = true
wait(1)
script.Disabled = false

Put this in a server script in workspace man

Please try utilizing print(plr.UserId, Owner.Value) after line 110 of the given script to ensure that it matches up.

Line 110: local Owner = target:FindFirstChild("Owner")

In addition, try utilizing print("Checkpoint") after line 115.

Line 115: game.ReplicatedStorage.PlaySoundRE:FireClient(plr)

We want to have further insight to help you as possible.

Try refrain from using .Disabled. It may work, but it may not be a viable option. If it’s done correctly, then it will work. If it doesn’t work, something is wrong. You may seek return as a possible alternative.

In addition, is Owner a StringValue or NumberValue?

1 Like

in a print, plr.UserId and Owner.Value give the same value. The line 113 dont work → if Owner.Value == plr.UserId then
Owner is a StringValue