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

How can I make it so the tool would be replaced?

I have this script where if you press on a part then it would give you a weapon. In my case the weapon/tool name is Sandalphon. I have the same thing for a different part but instead when you press it you would get a weapon/tool named Yoshinon. I need help on how I can make it so if I have one tool I can't have the other too and if I currently have Sandalphon then when I press on the other part (Yoshinon Part) it would remove Sandalphon giving me Yoshinon and if so could you include instructions?

local Giver = script.Parent
local Click = Giver:WaitForChild("Click")
local rp = game:GetService("ReplicatedStorage")

Click.MouseClick:Connect(function(player)
local Backpack = player:FindFirstChild("Backpack")
if Backpack then
	
local Angels = game:GetService("ServerStorage"):WaitForChild("Angels")

local AngelW = Angels.Tohka1:FindFirstChild("Sandalphon"):Clone()
AngelW.Parent = Backpack
Click.MaxActivationDistance = 0
print("You got Tohka's Angel")
local meshes = game.Workspace.JustForTestngPhase.Sandalphon.AngelGiver.Meshes:Clone()
				local me = meshes.explosion
				local mer = meshes.explosionring2
				local mer1 = meshes.explosionring
				local mer3 = meshes.explosionring3
				meshes.Parent= game.Workspace		
				me.CFrame = Giver.HumanoidRootPart.CFrame 
				mer.CFrame = Giver.HumanoidRootPart.CFrame 
				mer1.CFrame = Giver.HumanoidRootPart.CFrame 
				mer3.CFrame = Giver.HumanoidRootPart.CFrame 
		
for i = 1,125 do
	me.Color = Color3.new(math.random(), math.random(), math.random())
	me.Size = me.Size + Vector3.new(2,2,2)
	mer.Size = mer.Size + Vector3.new(2,0,2)
	mer1.Size = mer1.Size + Vector3.new(2,0,2)
	mer3.Size = mer3.Size + Vector3.new(2,0,2)
	me.Orientation = me.Orientation + Vector3.new(0,4,0)
	mer.Orientation = mer.Orientation + Vector3.new(0,4,0)
	mer1.Orientation = mer1.Orientation + Vector3.new(0,4,0)
	mer3.Orientation = mer3.Orientation + Vector3.new(0,4,0)
	me.Transparency = me.Transparency + 0.01
	mer.Transparency = mer.Transparency + 0.01
	mer1.Transparency = mer1.Transparency + 0.01
	mer3.Transparency = mer3.Transparency + 0.01
	wait(0.01)
end	
end
Giver:Destroy()
end)

1 comment

0

Nvm found the answer at least thanks for looking for it.

1 answer

✓ Accepted answer

I had found the answer but just in case someone in the near future is looking to make their own game and needs some help with things like this here you go.

local Giver = script.Parent
local Click = Giver:WaitForChild("Click")
local rp = game:GetService("ReplicatedStorage")


Click.MouseClick:Connect(function(player)
local Backpack = player:FindFirstChild("Backpack")

local FindTool = Backpack:FindFirstChild("Yoshinon") ----all this mean is that the game is going to look for the weapon
if Backpack then
	
	 if FindTool then----if it does find the tool
     FindTool:Destroy()----then destroy the tool, then shortly after you would get your new weapon yayy :D

local Angels = game:GetService("ServerStorage"):WaitForChild("Angels")

local AngelW = Angels.Tohka1:FindFirstChild("Sandalphon"):Clone()
AngelW.Parent = Backpack
Click.MaxActivationDistance = 0
print("You got Tohka's Angel")
local meshes = game.Workspace.JustForTestngPhase.Sandalphon.AngelGiver.Meshes:Clone()
				local me = meshes.explosion
				local mer = meshes.explosionring2
				local mer1 = meshes.explosionring
				local mer3 = meshes.explosionring3
				meshes.Parent= game.Workspace		
				me.CFrame = Giver.HumanoidRootPart.CFrame 
				mer.CFrame = Giver.HumanoidRootPart.CFrame 
				mer1.CFrame = Giver.HumanoidRootPart.CFrame 
				mer3.CFrame = Giver.HumanoidRootPart.CFrame 
		
for i = 1,125 do
	me.Color = Color3.new(math.random(), math.random(), math.random())
	me.Size = me.Size + Vector3.new(2,2,2)
	mer.Size = mer.Size + Vector3.new(2,0,2)
	mer1.Size = mer1.Size + Vector3.new(2,0,2)
	mer3.Size = mer3.Size + Vector3.new(2,0,2)
	me.Orientation = me.Orientation + Vector3.new(0,4,0)
	mer.Orientation = mer.Orientation + Vector3.new(0,4,0)
	mer1.Orientation = mer1.Orientation + Vector3.new(0,4,0)
	mer3.Orientation = mer3.Orientation + Vector3.new(0,4,0)
	me.Transparency = me.Transparency + 0.01
	mer.Transparency = mer.Transparency + 0.01
	mer1.Transparency = mer1.Transparency + 0.01
	mer3.Transparency = mer3.Transparency + 0.01
	wait(0.01)
end	
end
Giver:Destroy()
end----to end the part where you do get the weapon
end)

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