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

Why does the anchor false script not work on this script?

Asked by 4 years ago
player = script.Parent.Parent 
Mouse = player:GetMouse()
mag = game.Workspace.mag

Mouse.KeyDown:connect(function(Key)
    Key = Key:lower()
    if Key == 'r' then
        mag.Anchored = false
        wait(2)
        mag.Transparency = 1
        wait(3)
        mag.Anchored = true
        mag.Transparency = 0
        mag.CFrame = game.workspace.aaaaa.CFrame
    end
end)

The 'anchored = false' does not work, but the transparency does. Why?

0
is it welded to anything? FlabbyBoiii 81 — 4y
0
if it is you may want to break the weld, otherwise I don't see why it wouldn't go unanchored, unless there's some info you haven't given about what the 'mag' is FlabbyBoiii 81 — 4y
0
it's not kingbooker48 25 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Probably because the change is being done on the client.


You see, client changes only show for the client that made them. They do not replicate to the server.

So that is where remotes come in.

Here is some pseudocode:

remote_event.OnServerEvent:Connect(function(client)
    unanchor mag
    wait(2)
    make mag transparent
    wait(3)
    anchor mag
    make mag opaque
    set mag's cframe to game.Workspace.aaaaa.CFrame
end)

Also, Mouse.KeyDown is deprecated, don't use it. Instead, use UserInputService or ContextActionService.

Here is an example:

-- with context action service

local ContextActionService = game:GetService("ContextActionService")

ContextActionService:BindAction("Keybind", function()
    remote_event:FireServer()
end, false, Enum.KeyCode.R)

Links

0
Yeah The Change Is Probably On A Client Script Becuase It Has A Mouse Varible And I Think Only Clients Can Use Them ew_001 58 — 4y
Ad

Answer this question