Hello! I am Domderp999. The Creator of a future game called, “Volcano Madness,” and I am currently struggling with some shop / buy tool issues… (Only the Jetpack Tool) When the player buys the jetpack, it gives it to them, however, its almost like the Jetpack tool lost ALL of its code… The way the system works, is if you click buy on the GUI, it clones a tool in the Replicated Storage, and puts it in the Players Backpack. The Local script for the Buy button, fires a remote event in the replicated storage which a server script receives and gives the player the tool. This is the code inside the “Buy” Button :
script.Parent.MouseButton1Click:Connect(function()
local BuyLabelButton = script.BuyLabelButton.Value
local MainBuyObject = script.MainBuyObject.Value
local Price = script.ObjectCost.Value
local Player = game.Players.LocalPlayer
if Player.leaderstats.Points.Value >= Price then
--Player.leaderstats.Points.Value = Player.leaderstats.Points.Value - Price
--local CLN = MainBuyObject:Clone()
--CLN.Parent = Player.Backpack
script.Parent.Parent.Visible = false
game.ReplicatedStorage.GiveShopTool:FireServer(MainBuyObject)
else
script.Parent.Text = "You dont have enough money."
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 98, 98)
script.Parent.Parent.BackgroundColor3 = Color3.fromRGB(255, 66, 66)
wait(2.5)
script.Parent.Text = "Buy!"
script.Parent.BackgroundColor3 = Color3.fromRGB(139, 255, 137)
script.Parent.Parent.BackgroundColor3 = Color3.fromRGB(75, 244, 75)
end
end)
This code sets object values that help the code. (I have tested, and concluded that the values are not the problem.) The code also fires the Server script that gives the tool to the player. (Ignore the --, as they are just me referencing stuff in the past.)
This is the code in the server script that receives the Remote event fired by the code I just showed you. The server code just adds the tool to the players backpack. (Obviously)
Server Script:
game.ReplicatedStorage.GiveShopTool.OnServerEvent:Connect(function(Player,object)
local CL = object:Clone()
CL.Parent = Player.Backpack
end)
The Object Parameter is so the script knows what tool to give the player. All of the code works, exept the Jetpack Tool… The Jetpack tools code is this :
local ContextActionService = game:GetService("ContextActionService")
local bodyForce = Instance.new("BodyForce")
local Player = game.Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local Animation = Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent.Animation)
local UIS = game:GetService("UserInputService")
script.Parent.Equipped:Connect(function()
---------------
-- Variables --
local FlightSpeed = 60
local ThrustPower = 3800
-- Variables
---------------
script.Parent.EquippedV.Value = true
bodyForce.Force = Vector3.new(0,0,0)
script.Parent.Handle.Locked = false
bodyForce.Parent = script.Parent.Handle
UIS.InputBegan:Connect(function(keyCode)
if keyCode.keyCode == Enum.KeyCode.Space and script.Parent.EquippedV.Value == true then
script.Parent.Handle.Attachment.ParticleEmitter.Enabled = true
script.Parent.Handle.Attachment2.ParticleEmitter.Enabled = true
script.Parent.Handle.FuelLights.SurfaceLight.Enabled = true
bodyForce.Force = Vector3.new(0,ThrustPower,0)
Player.Character.Humanoid.WalkSpeed = FlightSpeed
Animation:Play()
end
end)
UIS.InputEnded:Connect(function(keyCode)
if keyCode.keyCode == Enum.KeyCode.Space then
script.Parent.Handle.Attachment.ParticleEmitter.Enabled = false
script.Parent.Handle.Attachment2.ParticleEmitter.Enabled = false
script.Parent.Handle.FuelLights.SurfaceLight.Enabled = false
bodyForce.Force = Vector3.new(0,0,0)
Player.Character.Humanoid.WalkSpeed = 16
Animation:Stop()
end
end)
end)
script.Parent.Unequipped:Connect(function()
script.Parent.EquippedV.Value = false
end)
Now, I dont understand whats happening… The Jetpack works in StarterPack, but not when the tool is duplicated and gaven to by the server script. I shall now show you the difference between when its in StarterPack, and when the serverscript gives it to the player. The difference, is the one that you I put in the starterpack, is you are actually able to fly around and it works great. But when it gets given to you from the server script clone script, you jump and nothing happens… Its really strange. Keep in mind the tool is the same as when it gets released and the same as when its in the starterpack.