I have created a system in my game where when a player purchases a nuke, the nuke will launch and explode upon hitting the ground. I’ve already scripted everything for this, but I’m experiencing issues. When the nuke is purchased, it only plays the audio and doesn’t trigger the nuke.
heres the script:
local ts = game:GetService(“TweenService”)
local mps = game:GetService(“MarketplaceService”)
local remoteEvent = game.ReplicatedStorage:WaitForChild(“NukeFolder”):WaitForChild(“NukeRemoteEvent”)
local isNuking = game.ReplicatedStorage.NukeFolder:WaitForChild(“IsNuking”)
local productId = game.ReplicatedStorage.NukeFolder:WaitForChild(“DeveloperProductId”).Value
local nukeButton = script.Parent:WaitForChild(“NukeButton”)
local nukeLabel = script.Parent:WaitForChild(“NukeMessageLabel”)
nukeLabel.Text = “”
nukeLabel.Visible = false
function changeButtonState()
nukeButton.Visible = not isNuking.Value
end
changeButtonState()
isNuking:GetPropertyChangedSignal(“Value”):Connect(changeButtonState)
function promptPurchase()
if isNuking.Value == false then
mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
end
end
nukeButton.MouseButton1Click:Connect(promptPurchase)
remoteEvent.OnClientEvent:Connect(function(instruction, info)
if instruction == "nuke message" then
nukeLabel.Visible = true
for i = 1, string.len(info) do
nukeLabel.Text = string.sub(info, 1, i)
wait(0.05)
end
wait(5)
for i = string.len(info), 0, -1 do
nukeLabel.Text = string.sub(info, 1, i)
wait(0.05)
end
nukeLabel.Visible = false
elseif instruction == "shake camera" then
while game.Players.LocalPlayer.Character.Humanoid.Health > 0 do
local x = Random.new():NextNumber(-0.25, 0.25)
local y = Random.new():NextNumber(-0.25, 0.25)
local z = Random.new():NextNumber(-0.25, 0.25)
game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(x, y, z)
workspace.CurrentCamera.CFrame *= CFrame.Angles(x/5, y/5, z/5)
wait()
end
elseif instruction == "lighting effect" then
local cc = Instance.new("ColorCorrectionEffect")
cc.Parent = game.Lighting
local ccTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local ccTween = ts:Create(cc, ccTweenInfo, {Brightness = 1, Contrast = 1, TintColor = Color3.fromRGB(255, 170, 0)})
ccTween:Play()
wait(game.Players.RespawnTime - 1)
cc:Destroy()
end
end)