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

How to fix the code i added to a grenade code from a free model?

I have a grenade code I took from a free model and it looks like


 local player =  game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local config = tool:WaitForChild("Configurations")

local canThrow = true

tool.Equipped:connect(function()
	mouse.Icon = "rbxasset://textures/GunCursor.png"
end)

tool.Unequipped:connect(function()
	mouse.Icon = ""
end)

tool.Activated:connect(function()
	if canThrow then
		canThrow = false
		local throwAnimation = player.Character.Humanoid:LoadAnimation(tool.ThrowAnimation)
		throwAnimation:Play() -- Load and play the throwing animation
		
		throwAnimation.KeyframeReached:connect(function(keyframe) -- Wait 'til we reach a keyframe
			if keyframe == "tick" then -- if the keyframe is 'tick' then play the pin sound
				tool.Handle.Pin:Play()
			elseif keyframe == "throw" then -- otherwise, if it's 'throw,' tell the serverscript to throw our grenade
				tool.Throw:FireServer(mouse.Hit.p)
				throwAnimation:Stop()
				mouse.Icon = "rbxasset://textures/GunWaitCursor.png"
			end
		end)
		wait(config.Cooldown.Value)
		mouse.Icon = "rbxasset://textures/GunCursor.png"
		canThrow = true
	end
end)

and I added a bit of code at the end to hide my mesh after its been thrown and it looks like this

game.Workspace.["The Holy Hand Nuke"].handle.["flight mesh"].Transparency = 1

and it doesn't hide the mesh after its thrown the whole code looks like this


local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local config = tool:WaitForChild("Configurations")

local canThrow = true

tool.Equipped:connect(function()
	mouse.Icon = "rbxasset://textures/GunCursor.png"
end)

tool.Unequipped:connect(function()
	mouse.Icon = ""
end)

tool.Activated:connect(function()
	if canThrow then
		canThrow = false
		local throwAnimation = player.Character.Humanoid:LoadAnimation(tool.ThrowAnimation)
		throwAnimation:Play() -- Load and play the throwing animation
		
		throwAnimation.KeyframeReached:connect(function(keyframe) -- Wait 'til we reach a keyframe
			if keyframe == "tick" then -- if the keyframe is 'tick' then play the pin sound
				tool.Handle.Pin:Play()
			elseif keyframe == "throw" then -- otherwise, if it's 'throw,' tell the serverscript to throw our grenade
				tool.Throw:FireServer(mouse.Hit.p)
				throwAnimation:Stop()
				mouse.Icon = "rbxasset://textures/GunWaitCursor.png"
			end
		end)
		wait(config.Cooldown.Value)
		mouse.Icon = "rbxasset://textures/GunCursor.png"
		canThrow = true
	end
end)

game.Workspace["The Holy Hand Nuke"].handle.["flight mesh"].Transparency = 1

(sorry if this is long but first post here)

1 answer

✓ Accepted answer

Nevermind I didn't need to delete it just needed to delete the texture id

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