Hi, I am trying to add a feature where if a player owns a gamepass the roll speed is cut in half. The problem i am having is that I try to use game.Players.PlayerAdded:Connect(function(player)
to detect the player but for some reason it doesnt work. The script is a server script inside of a gui button and I want it to first detect the player, if they have the gamepass and then act accordingly wether they have it or not. I have tried to just simply put
game.Players.PlayerAdded:Connect(function(player)
print("Joined")
end)
as a way of testing it but that doesnt work inside the script either. This exact code works in a script elsewhere though. Therefore i assume that due to the location of the script that way of detecting the player wont work but i dont know how else i can do this.
This is my script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FormatNumber = require(ReplicatedStorage.FormatNumber.Simple)
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 1143140303
local canClick = true
script.Parent.MouseButton1Click:Connect(function()
if not canClick then return end
canClick = false
local fakeRewards, reward = game.ReplicatedStorage.Function:Invoke()
local myString = reward[4]
local splitted = string.split(myString, ", ")
local colour = Color3.fromRGB(tonumber(splitted[1]), tonumber(splitted[2]), tonumber(splitted[3]))
script.Parent.Parent.RollFrame.RewardContainer.RewardText.Text = reward[1]
script.Parent.Parent.RollFrame.RewardContainer.RewardChance.Text = '1 in '..tostring(FormatNumber.FormatCompact(reward[2]))
script.Parent.Parent.RollFrame.RewardContainer.RewardPrice.Text = '$'..FormatNumber.FormatCompact(reward[3])
script.Parent.Parent.RollFrame.RewardContainer.RewardText.TextColor3 = Color3.fromRGB(tonumber(splitted[1]), tonumber(splitted[2]), tonumber(splitted[3]))
game.Workspace.GameTime.Value = 2
script.Parent.Parent.Parent.Countdown.TextLabel.Visible = true
script.Parent.Parent.RollFrame.Visible = true
wait(2)
script.Parent.Parent.RollFrame.Visible = false
script.Parent.Parent.Parent.Countdown.TextLabel.Visible = false
canClick = true
end)