Why doesn't my script does what I say it does?

I made a local script inside of a tool with the intention that when a player equips the tool, it will disable a local script insiide of starter player scripts, and then also clone a different script and put the cloned script inside of starter player scritps, however this does not happen. Nothing happens. Why is this?

local Player = game.Players.LocalPlayer
local OriginalSlide = game.StarterPlayer.StarterPlayerScripts.Slide
local M4A1Slide = game.ReplicatedStorage.M4A1Slide
local M4A1Slide2 = game.StarterPlayer.StarterPlayerScripts.M4A1Slide

function onToolEquipped()
	game.OriginalSlide.Disabled = true
	local M4A1SlideClone = M4A1Slide:Clone()
	M4A1SlideClone.parent = game.StarterPlayer.StarterPlayerScripts
end

function onToolUnequipped()
	game.OriginalSlide.Disabled = false
	M4A1Slide2:Destroy()
end

function onDeath()
	game.OriginalSlide.Disabled = false
	M4A1Slide2:Destroy()
end

script.Parent.Equipped:connect(onToolEquipped)
script.Parent.Unequipped:connect(onToolUnequipped)
Player.Died:connect(onDeath)

Try adding print statements to see if any of the code is activating at all, and where it stops working as expected.

1 Like

I can second this, It often helps me out aswell.

function onToolEquipped()
	OriginalSlide.Disabled = true
	local M4A1SlideClone = M4A1Slide:Clone()
	M4A1SlideClone.parent = game.StarterPlayer.StarterPlayerScripts
end

function onToolUnequipped()
	OriginalSlide.Disabled = false
	M4A1Slide2:Destroy()
end

function onDeath()
	OriginalSlide.Disabled = false
	M4A1Slide2:Destroy()
end

Dont… dont clone it into the starter character script… clone it into the

game.WorkSpace:FindFirstChild("PlayerName")

or

game.Players.LocalPlayer.Character

Exactly! Localscripts can’t clone another script into a player folder, at least from my experience it cannot be done by the client

Update: I’m banned from roblox for 3 days so that might be why nothing works :skull:

Perhaps its because I’m banned but I put print statements right below the function onToolEquipped() line and nothing printed, which is odd because it should have printed.

Have you verified that the event connection is made, and have you verified if the script is running at all?