Hello Devs! I am trying making a launcher skin store where players can buy skins with in game currency
When i go to buy the launchers from the shop the launchers dont shoot the only gun that shoots is the gun that is given to the player by default. it still makes the sound and everything but no bullet comes out. Also any skins that are animated do not play theyre animation when i buy them from the shop. the guns work outside the shop if i pick them up or put them in the starter pack. but as soon as you put them in replicated storage they dont work.
This is the script i use for all the guns in the game to make them fire.
local tool = script.Parent
local fireEvent = tool.FireEvent
local FastCast = require(tool.FastCastRedux)
local firePoint = tool.OilSpill.FirePoint
local bulletsFolder = workspace:FindFirstChild("BulletFolder") or Instance.new("Folder", workspace)
bulletsFolder.Name = "bulletFolder"
FastCast.VisualizeCasts = true
local bulletTemplate = Instance.new("Part")
bulletTemplate.Anchored = true
bulletTemplate.CanCollide = false
bulletTemplate.Shape = "Ball"
bulletTemplate.Size = Vector3.new(1,1,1)
bulletTemplate.Material = Enum.Material.Metal
local caster = FastCast.new()
local castParams = RaycastParams.new()
castParams.FilterType = Enum.RaycastFilterType.Blacklist
castParams.IgnoreWater =true
local castBehavior = FastCast.newBehavior()
castBehavior.RayCastParams = castParams
castBehavior.Acceleration = Vector3.new(0, -workspace.Gravity, 0)
castBehavior.AutoIgnoreContainer = false
castBehavior.CosmeticBulletContainer = bulletsFolder
castBehavior.CosmeticBulletTemplate = bulletTemplate
local function onEquipped()
castParams.FilterDescendantsInstances = {tool.Parent, bulletsFolder}
end
local function onLengthChanged(cast,lastPoint, direction, length, velocity, bullet)
if bullet then
local bulletLength = bullet.Size.Z/2
local offset = CFrame.new(0, 0,-(length - bulletLength))
bullet.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
end
end
local function onRayHit(cast, result, velocity, bullet)
local hit = result.Instance
local character = hit:FindFirstAncestorWhichIsA("Model")
if character and character:FindFirstChild("Humanoid") then
character.Humanoid:TakeDamage(100)
end
game:GetService("Debris"):AddItem(bullet, .5)
end
local function fire(player, mousePositon)
local origin =firePoint.WorldPosition
local direction = (mousePositon- origin).Unit
caster:Fire(origin, direction, 300, castBehavior)
end
fireEvent.OnServerEvent:Connect(fire)
tool.Equipped:Connect(onEquipped)
caster.LengthChanged:Connect(onLengthChanged)
caster.RayHit:Connect(onRayHit)
This is the script i use to take money from the player and give them the new skin. Oil Spill is the name of the skin in this one.
ocal player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.USD.Value >= 5000 then
player.leaderstats.USD.Value = player.leaderstats.USD.Value - 5000
local clonar = game.ReplicatedStorage.OilSpill:Clone()
clonar.Parent = player.Backpack
end
end)
If theyre are any other screenshots, videos or codes you would like to see please let me know and ill get them as soon as i can. Thanks for reading.