Local Script works for me but not for others?

Hello!

i have been working on a game and gotten to maken a button wich if u touch it blocks appear, whenever i test this it works completely fine but whenever my friend tries this it never even starts, ive tried to replicate this bug by using local servers to no success,

I have no idea what the issue is exactly since im unable to replicate the bug but here is part of the script

local Players = game:GetService(“Players”)
local TweenService = game:GetService(“TweenService”)

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local RootPart = Character:WaitForChild(“HumanoidRootPart”)
local Leg = Character:WaitForChild(“Left Leg”)

local MechanicsFolder = workspace:WaitForChild(“ObstacleSpawn”)
local ButtonFolder = MechanicsFolder:WaitForChild(“ButtonBlocks”)

for _, Buttons in pairs(ButtonFolder:GetChildren()) do
if Buttons:IsA(“Model”) or Buttons:IsA(“Folder”) then

  local ButtonModdel = Buttons:FindFirstChild("Button")
  local TopButton = ButtonModdel:FindFirstChild("Top")
  local Blocks = Buttons:FindFirstChild("Blocks")
  local WaitTime = Buttons:FindFirstChild("WaitTime")
  
  for _, block in pairs(Blocks:GetChildren()) do
  	local val = Instance.new("Vector3Value")
  	val.Name = "Fullsize"
  	val.Value = block.Size
  	val.Parent = block

  	local colval = Instance.new("Color3Value")
  	colval.Name = "Origcolor"
  	colval.Value = block.Color
  	colval.Parent = block

  	block.Size = Vector3.new(0,0,0)
  	block.Transparency = 1
  	block.CanCollide = false
  end	

If anybody as any idea of what could cause this thank you very much and have a nice day/night!

What is the section of script that deals with the player touching the button?
You can do print statements in that section when the button is pressed that print the name of the player that touched it. From that you can determine if the button is registering the touched event, or if you need to troubleshoot something different.
Don’t just troubleshoot with lines like print("button pressed") because if your code isn’t right and a regular Part fires the Touched event then it’ll print that as well.
When you have an if ... then statement that relies on a variable and it isn’t working the way you think it should be, then print the variable before the if statement so you can see what it actually is.

this is the section that handles the touching , the main issue is that i am having no errors whatsoever but when my friend joins me and tries it it doesnt work at all

TopButton.Touched:connect(function(hit)

  	if Player.Name ~= hit.Parent.Name then return end
  	
  	if hit.Name == "Left Leg" or hit.Name == "Right Leg" then
  		if buttondebounce == true then return end
  		buttondebounce = true
  		
  		local colorsave = TopButton.Color
  		wait(0.001)
  		TopButton.Color = Color3.new(27/255, 42/255, 53/255)
  		TopButton.Size = Vector3.new(1, 8, 8)
  		local style = Enum.EasingStyle.Sine
  		local dir = Enum.EasingDirection.InOut
  		local shifttime = 0.5
  		
  		for _, block in pairs(Blocks:GetChildren()) do
  			block.Transparency = 0
  			block.CanCollide = true
  			TweenService:Create(block, TweenInfo.new(shifttime, style, dir),{ Size = block:WaitForChild("Fullsize").Value }):Play()
  			
  		end
  		
  		local timevalue = WaitTime.Value

  		local halftime = timevalue/2
  		local increment = 0.5
  		
  		repeat
  			timevalue = timevalue - increment
  			
  			TopButton.SurfaceGui.Frame.TextLabel.Text = (timevalue - (timevalue%1))+1
  			
  			if timevalue <= halftime and halftime >= increment then
  				halftime = halftime/2

  				for _, block in pairs(Blocks:GetChildren()) do
  					block.Material = "SmoothPlastic"
  					block.Color = Color3.new(math.min(block.Color.R + 0.25, 1), math.min(block.Color.G + 0.25, 1), math.min(block.Color.B + 0.25, 1))
  				end
  				task.wait(increment/2)
  				for _, block in pairs(Blocks:GetChildren()) do
  					block.Material = "SmoothPlastic"
  					block.Color = block.Origcolor.Value
  				end
  				task.wait(increment/2)
  			else
  				task.wait(increment)
  			end
  			
  		until timevalue <= 0 
  		
  		for _, block in pairs(Blocks:GetChildren()) do
  			local completetween = TweenService:Create(block, TweenInfo.new(shifttime, style, dir),{ Size = Vector3.new(0,0,0) })

  			completetween.Completed:Connect(function(playbackState)
  				if (playbackState == Enum.PlaybackState.Completed) then
  					block.CanCollide = false
  					block.Transparency = 1
  				end
  			end)

  			completetween:Play()
  		end
  		
  		TopButton.Color = colorsave
  		TopButton.Size = Vector3.new(1.5, 8, 8)
  		TopButton.SurfaceGui.Frame.TextLabel.Text = '!'

  		buttondebounce = false
  	end
  end)

That’s why I said print the player that touched the button.
For this one put
print(Player.Name, " ", hit.Parent.Name)
ahead of the first if statement.
It’ll tell you why the first or second if isn’t true to press the button.

In a situation like this you may not get an error because something you’ve coded makes it so that Player.Name never equals hit.Parent.Name.
Your friend may have a shoe Accessory that is having the name printed, so it isn’t left or right leg.

i see thank you, but what also happens for them is that this part :

for _, block in pairs(Blocks:GetChildren()) do
local val = Instance.new(“Vector3Value”)
val.Name = “Fullsize”
val.Value = block.Size
val.Parent = block

  	local colval = Instance.new("Color3Value")
  	colval.Name = "Origcolor"
  	colval.Value = block.Color
  	colval.Parent = block

  	block.Size = Vector3.new(0,0,0)
  	block.Transparency = 1
  	block.CanCollide = false

end

Never even happens for them

‘Never even happens to them’.
Do you mean the blocks never get the Vector3Value?
Or do they only show up on your client?

Where is the local script located? If you want the Vector3 to be inserted into the blocks on their client as well then the script would need to be run on their client.

The problem you’re going to probably have is that if all of this is located on each client then someone can alter those numbers/colors/properties.

I’m thinking this script should be on the server. You can set all those properties/instances on the server, and do all the coding from that end.

yes i mean they never get the vector3value, and the script is located in a folder in Starterplayerscripts, and the reason why i am using a local scripts is mainly because its a platformer game and its more fun if u “figure things out yourself” if you get what i mean