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

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

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?

3 comments

0

is it welded to anything?

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

0

it's not

1 answer

✓ Accepted answer

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

1 comment

0

Yeah The Change Is Probably On A Client Script Becuase It Has A Mouse Varible And I Think Only Clients Can Use Them

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