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

Script not Starting,Won't Change properties when parent clicked?

I don't know why; no errors are being produced. Here is my code:

print("Script Active!")
script.Parent.MouseButton1Click:connect(function()
	print("Button1 Clicked")
	workspace.PrisonCell.Door.Bar1.Anchored = false
	workspace.PrisonCell.Door.Bar2.Anchored = false
	workspace.PrisonCell.Door.Bar3.Anchored = false
	workspace.PrisonCell.Door.Bar4.Anchored = false
	workspace.PrisonCell.Door.Bar5.Anchored = false
	workspace.PrisonCell.Door.Bar6.Anchored = false
	workspace.PrisonCell.Door.Main.Disabled = true
end)

There are no errors, or things being printed. it is in a starter Gui and is a normal script(not local). Is It my code? Or Is it roblox(I have tried Mousebutton1Down That Doesn't Work) Let me know if you need more info.

1 comment

1

well as you said its a server script so it wont work, it gotta be a local script

2 answers

✓ Accepted answer

This would work but it needs to be a local script rather than a server script. Also connect is deprecated, use Connect (capital C)

We live in FilteringEnabled times. That is client can not manipulate shared workspace, other than through moving his character, remote events and/or remote functions...

Change your script to localScript and edit like this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PrisonCellOpenRequest = ReplicatedStorage:WaitForChild("PrisonCellOpenRequest")

print("Script Active!")
script.Parent.MouseButton1Click:Connect(function()
	print("Button1 Clicked")
	local result = PrisonCellOpenRequest:InvokeServer()
	print(result)
end)

Then add this script to a ServerScriptStorage:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PrisonCellOpenRequest = Instance.new("RemoteFunction")
PrisonCellOpenRequest.Parent = ReplicatedStorage
PrisonCellOpenRequest.Name = "PrisonCellOpenRequest"

local function onPrisonCellOpenRequest(player)
	
	--you can add checks here if player is allowed to open the cell door here
	workspace.PrisonCell.Door.Bar1.Anchored = false
	workspace.PrisonCell.Door.Bar2.Anchored = false
	workspace.PrisonCell.Door.Bar3.Anchored = false
	workspace.PrisonCell.Door.Bar4.Anchored = false
	workspace.PrisonCell.Door.Bar5.Anchored = false
	workspace.PrisonCell.Door.Bar6.Anchored = false
	workspace.PrisonCell.Door.Main.Disabled = true
	return "Success"

end

PrisonCellOpenRequest.OnServerInvoke = onPrisonCellOpenRequest


Edit: Changed connect to Connect

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