Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

01print("Script Active!")
02script.Parent.MouseButton1Click:connect(function()
03    print("Button1 Clicked")
04    workspace.PrisonCell.Door.Bar1.Anchored = false
05    workspace.PrisonCell.Door.Bar2.Anchored = false
06    workspace.PrisonCell.Door.Bar3.Anchored = false
07    workspace.PrisonCell.Door.Bar4.Anchored = false
08    workspace.PrisonCell.Door.Bar5.Anchored = false
09    workspace.PrisonCell.Door.Bar6.Anchored = false
10    workspace.PrisonCell.Door.Main.Disabled = true
11end)

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
well as you said its a server script so it wont work, it gotta be a local script starmaq 1290 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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

Ad
Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
6 years ago
Edited 6 years ago

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:

1local ReplicatedStorage = game:GetService("ReplicatedStorage")
2local PrisonCellOpenRequest = ReplicatedStorage:WaitForChild("PrisonCellOpenRequest")
3 
4print("Script Active!")
5script.Parent.MouseButton1Click:Connect(function()
6    print("Button1 Clicked")
7    local result = PrisonCellOpenRequest:InvokeServer()
8    print(result)
9end)

Then add this script to a ServerScriptStorage:

01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02local PrisonCellOpenRequest = Instance.new("RemoteFunction")
03PrisonCellOpenRequest.Parent = ReplicatedStorage
04PrisonCellOpenRequest.Name = "PrisonCellOpenRequest"
05 
06local function onPrisonCellOpenRequest(player)
07 
08    --you can add checks here if player is allowed to open the cell door here
09    workspace.PrisonCell.Door.Bar1.Anchored = false
10    workspace.PrisonCell.Door.Bar2.Anchored = false
11    workspace.PrisonCell.Door.Bar3.Anchored = false
12    workspace.PrisonCell.Door.Bar4.Anchored = false
13    workspace.PrisonCell.Door.Bar5.Anchored = false
14    workspace.PrisonCell.Door.Bar6.Anchored = false
15    workspace.PrisonCell.Door.Main.Disabled = true
16    return "Success"
17 
18end
19 
20PrisonCellOpenRequest.OnServerInvoke = onPrisonCellOpenRequest

Edit: Changed connect to Connect

Answer this question