Define character model in workspace

  1. What do you want to achieve?
    To disable or enable the script in the character model.

  2. What is the issue?
    Im not sure on how to path to the camerabobbing script through the character model. Both are local scripts. I need it to only affect the player that enables or disables it.

  3. What solutions have you tried so far?
    Searched the dev forum.

while the game is running.

1 Like

what???
you know you can just get the character from the local player right? there’s no need for any of these

2 Likes

can you please elaborate on this. im no expert at scripting. Trying to make it work for the Gui menu.

I used local player for the motion blur toggle, but it does not work for the camera sway.

LocalPlayer refers to the Player instance, you need to do LocalPlayer.Character in order to get the character

also if you are making a game, please don’t when you’re just starting
don’t make the same mistake i did, learn on smaller things first, otherwise when you learn you’re gonna be in rewriting hell constantly

In both cases you have incorrectly addressed the path to the local player’s character (game.Players.LocalPlayer and game.Workspace.Character are not player characters), here’s how it should be done:

local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local scriptt = character:WaitForChild("CameraBobbing")

Note that the CameraBobbing script will reset if the character respawns.

I am going to give you Solution, but is there a way that i can make it permanent unless toggled even after respawn?

local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local scriptt = character:WaitForChild("CameraBobbing")
local enabled = scriptt.Enabled
button.MouseButton1Click:Connect(function()
     scriptt.Enabled = not scriptt.Enabled
     enabled = scriptt.Enabled
end)
plr.CharacterAdded:Connect(function(char)
     scriptt = char:WaitForChild("CameraBobbing") --otherwise the scriptt variable will be a script of parent nil because it was parented to a dead character
     scriptt.Enabled = enabled
end)

It still did not fix it reseting after respawn, but it works. I will just make a note for players to have to retoggle it.