In a server script you can not use local player, you must detect when a player joins and create a variable. Local player only works in local scripts.
Here is a way to detect a player entering:
game.Players.PlayerAdded:Connect(function(player)
end)
So for you it should be:
local sirens = game.Workspace.Map.Area47.Siren.Siren2
local Log = script.Parent.YN
local start = script.Parent.Start
local stop = script.Parent.Stop
local stress = game.StarterGui.SeverStress.TextLabel.Value
local MPS = game:GetService("MarketplaceService")
local AirStrikeID = 1082388187
local Players = game:GetService("Players")
local sirenson = false
game.Players.PlayerAdded:Connect(function(Player)
start.ClickDetector.MouseClick:Connect(function()
if stress.Value < 90 then
workspace.bombboi.Launching.Value = "N"
sirenson = false
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 0, 0)
Log.SurfaceGui.TextLabel.Text = "ERR:STRESS_NOT_ABOVE_90%"
wait(2)
Log.SurfaceGui.TextLabel.Text = ""
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 1, 1)
else
sirens.Sirens.Playing = true
sirens.Sirens.Volume = 10
sirenson = true
Log.SurfaceGui.TextLabel.Text = "Sirens Launched Would You Like To Purchase A Air Strike?"
wait(1)
MPS:PromptProductPurchase(Player,AirStrikeID)
if Enum.ProductPurchaseDecision.PurchaseGranted then
workspace.bombboi.Launching.Value = "Y"
else
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 0, 0)
Log.SurfaceGui.TextLabel.Text = "ERR:AIR_STRIKE_NOT_PURCHASED"
wait(2)
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 1, 1)
Log.SurfaceGui.TextLabel.Text = ""
end
end
end)
end)
ONLY USE BELOW IF YOU ARE USING A GAMEPASS AND NOT A DEVPRODUCT
But... it's not fixed yet, since around April 2018 you can no longer use PromtProductPurchase but now you must use PromtGamePassPurchase
So this should be the complete code:
local sirens = game.Workspace.Map.Area47.Siren.Siren2
local Log = script.Parent.YN
local start = script.Parent.Start
local stop = script.Parent.Stop
local stress = game.StarterGui.SeverStress.TextLabel.Value
local MPS = game:GetService("MarketplaceService")
local AirStrikeID = 1082388187
local Players = game:GetService("Players")
local sirenson = false
game.Players.PlayerAdded:Connect(function(Player)
start.ClickDetector.MouseClick:Connect(function()
if stress.Value < 90 then
workspace.bombboi.Launching.Value = "N"
sirenson = false
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 0, 0)
Log.SurfaceGui.TextLabel.Text = "ERR:STRESS_NOT_ABOVE_90%"
wait(2)
Log.SurfaceGui.TextLabel.Text = ""
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 1, 1)
else
sirens.Sirens.Playing = true
sirens.Sirens.Volume = 10
sirenson = true
Log.SurfaceGui.TextLabel.Text = "Sirens Launched Would You Like To Purchase A Air Strike?"
wait(1)
MPS:PromptGamePasstPurchase(Player,AirStrikeID)
if Enum.GamePasstPurchaseDecision.PurchaseGranted then
workspace.bombboi.Launching.Value = "Y"
else
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 0, 0)
Log.SurfaceGui.TextLabel.Text = "ERR:AIR_STRIKE_NOT_PURCHASED"
wait(2)
Log.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 1, 1)
Log.SurfaceGui.TextLabel.Text = ""
end
end
end)
end)
Extra help:
Player,
GamePassPurchaseFinished,
GamePassService
Leave a comment if you need more help or accept the answer if it worked!
5 comments
Is this a local script?
Script
dont spam this is your original: https://scriptinghelpers.org/questions/111949/marketplaceservicepromptproductpurchase-player-should-be-of-type-player-but-is-of-type-nil
Sorry. The Page Got Flooded With New Questions Yesterday
Please accept the most helpful answer. There should be an "accept" button to the right.