How do i get something inside of a player?

Trying to make a script for a tool that when equipped will enable a script inside of a player, and when unequipped will disable said script. Here is the code so far.

local tool = script.Parent
local player = script.Parent.Parent
local VMS = player.ViewModelScript

tool.Equipped:Connect(function()
	VMS.disabled = false

end)

tool.Unequipped:Connect(function()
	VMS.disabled = true
end)

I recommend game.Players.LocalPlayer to find the player

you are defining player before tool equips.

local tool = script.Parent
local player,VMS

tool.Equipped:Connect(function()
	player = script.Parent.Parent
	VMS = player.ViewModelScript

	VMS.Enabled = true

end)

tool.Unequipped:Connect(function()
	VMS.Enabled = false
end)

copy and pasted your script. it didnt work

i’ve edited script a little, plus tell me if it gave any errors and try the edited script

didnt work. nothing shows up in output

Then it works, you can just check if the script really disables, because i don’t know what “Disabling” that local script should do so i can’t know how to help.

this didn’t work either sadly for some reason