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?
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)