#Why wont this work?

130 messages · Page 1 of 1 (latest)

flat trench
#

game.Players.PlayerAdded:Connect(function(player)
    local timeValue = Instance.new("IntValue")
    timeValue.Name = "Time"
    timeValue.Value = 0
    timeValue.Parent = player

    while wait(1) do
        timeValue.Value = timeValue.Value + 1

        if timeValue.Value == 10 then
            game.ReplicatedStorage.FirePoorPersonCutscene:FireAllClients(player)
        end
    end
end)```
rich patrol
#

It should 100% work

tribal condor
#

is it a local script lmao

toxic venture
tribal condor
#

it allways happens

azure lotus
#

are u still having problems?

azure lotus
#

The provided script listens for new players joining the game and creates a new IntValue named "Time" for each player. It then increments the value of "Time" every second until it reaches 10, at which point it fires a cutscene for the player using a replicated event. However, there are a few improvements that can be made to the script:

The script currently uses an infinite while wait(1) do loop, which can potentially cause performance issues. Instead, you can use a RunService.Heartbeat connection to update the time value every frame.

The script uses game.ReplicatedStorage.FirePoorPersonCutscene:FireAllClients(player) to fire the cutscene for the player. It's unclear what this event does, so please make sure that it is implemented correctly on the server and that the clients are listening for it.

regal quarryBOT
#

studio** You are now Level 6! **studio

azure lotus
#

here is the new and fixed version

#

local Players = game:GetService("Players")

local function updateTime(player)
local timeValue = Instance.new("IntValue")
timeValue.Name = "Time"
timeValue.Value = 0
timeValue.Parent = player

local function updateValue()
    timeValue.Value = timeValue.Value + 1
    
    if timeValue.Value == 10 then
        game.ReplicatedStorage.FirePoorPersonCutscene:FireAllClients(player)
    end
end

game:GetService("RunService").Heartbeat:Connect(updateValue)

end

Players.PlayerAdded:Connect(updateTime)

#

@toxic venture

#

@flat trench

#

sorry for the ping dark

#

it was on accident

toxic venture
#

Ur chill

azure lotus
#

yo mb

#

i just saw the notification

azure lotus
azure lotus
#

@flat trench

muted glade
#

Dont use playeradded on local scripts

#

Local scripts start running when the player joins

#

Idk if this is a dumb suggestion but maybe create the time variables and update them on the server?

#

Idk if remote events fired from a client can fire a client, but im new to scripting so idk

#

If you create something on a local script it will stay on the client

#

So your time thing will only stay on the client

flat trench
#

Sorry I couldn't talk

flat trench
#

@azure lotus

#

its supoosed to add 1 every 1 second

tribal condor
#

@toxic venture i fucking told uu

flat trench
#

also

#

it only the remote event that wont work

#

@azure lotus

tribal condor
#

remote event is from client to server

flat trench
#

what

#

im new to scripting

tribal condor
#

remote event is client to server

flat trench
#

what is client to server

tribal condor
#

..

#

basically

#

player

#

player talks to server

flat trench
#

ok

tribal condor
#

to talk server to server its a bindable event

flat trench
#

ok

#

but why wont it work

toxic venture
regal quarryBOT
#

studio** You are now Level 5! **studio

flat trench
#

it is a script

#

is it supposed to be a local script?

toxic venture
flat trench
#

ok

toxic venture
#

To use player added, always do a script

#

If its a local script

#

Then no need

flat trench
#

ok

#

but do you know why the remote event wont work?

toxic venture
toxic venture
#

Server

#

In your case

#

Although im not sure because I only just came here

flat trench
#

olr

regal quarryBOT
#

studio** You are now Level 7! **studio

flat trench
#

alr

#

@tribal condor

#

can you tell me why it wont work

tribal condor
#

cause ur tryna talk from server to server, with a thing that talks from client to server

flat trench
#

local script?

tribal condor
#

....

flat trench
#

what do i need to do

tribal condor
#

learn to script

flat trench
#

bruh

#

how do i fix it

#

@tribal condor

tribal condor
#

idk ask drk

#

idk how to

flat trench
#

he said he doesnt know...

tribal condor
#

idk either

#

sucks to suck ig

flat trench
#

hmmmmm

toxic venture
#

So

#

Sebd the script that happens when the event is triggered

#

And make sure it is a local script in starterplayerscripts

flat trench
#

ok

#

still wont work

flat trench
#

there are multiple

#

but the main one

toxic venture
#

What did you thrn into a local script

flat trench
#

is a cutscene plugin

#

yes

toxic venture
#

Right

#

Listen

tribal condor
#

Script:

local Players = game:GetService("Players")

function giveTime(player)
    while wait(1) do
        player.Time.Value += 1
        
        if player.Time.Value == 10 then
            game.ReplicatedStorage.FirePoorPersonCutscene:FireAllClients()
        end
    end
end

Players.PlayerAdded:Connect(function(player)
    local TimeV = Instance.new("IntValue")
    TimeV.Name = "Time"
    TimeV.Value = 0
    TimeV.Parent = Players
    giveTime(player)
end)

Local script:

game.ReplicatedStorage.PoorPersonCutscene.OnClientEvent:Connect(function()
    --Cutscene code
end)

Use a remote event btw

toxic venture
#

There

flat trench
#

wher do i put them

tribal condor
#

no its not

#

ur firing from server

#

to client

#

so onclientevent is correct..

toxic venture
#

Oh mb thought it was a client

flat trench
#

its a cutscene plugin so it wrote the code

#

do u need to see it?

toxic venture
#

Is there ant errors

#

Any errors

flat trench
#

no

tribal condor
#

does it work?

flat trench
#

i didint try it yet 1 sec

tribal condor
#

k

flat trench
#

the value time never gets any value

#

nvm

#

it adds in increments of 2

#

wait its bc i have my other script running

#

nvm it still deos

#

does

#

many errors

#

i ran it a few times

#

@tribal condor

#

r u there?

#

@toxic venture

#

btw the sound id is for smth else

tribal condor
#

none of thse errors have to do with the script i gave u

flat trench
#

ok

azure lotus
#

@flat trench what was ur problem or is it solved?

flat trench
#

iits not solved