Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why can't I change a variable from a different script?

I tried making a currency and a minigame and what is supposed to happen is that if you get first, you would get that currency, but it never works.

local w = game.ServerScriptService.v:FindFirstChild(Wins)
local p = 0
if workspace.Parkour.PWalls.Winplat.Touched:Connect(FindFirstChild("Humanoid")) and p < 1 then
 w = w + 1
 p = p + 1
else
	p = p + 1
end

If anyone could help me, that would be great.

1 answer

Access the value, not the int itself. When using FindFirstChild the correct syntax is (" "), since you're searching for a name.

local w = game.ServerScriptService.v:FindFirstChild("Wins")
local p = 0
if workspace.Parkour.PWalls.Winplat.Touched:Connect(FindFirstChild("Humanoid")) and p < 1 then
	w.Value = w.Value + 1
	p = p + 1
else
p = p + 1
end

I think this is what you want though, the if statement will only run once, if you put it into a touched function it will watch for the touch.

local w = game.ServerScriptService.v:FindFirstChild("Wins")
local t = FindFirstChild("Humanoid")
local p = 0

workspace.Parkour.PWalls.Winplat.Touched:Connect(function(t)
	if p < 1 then
		w.Value = w.Value + 1
		p = p + 1
	else
		p = p + 1
	end
end)

10 comments

0

You forgot to say that he didn't change Wins into "Wins"

0

I corrected it but forgot to mention it, thanks.

0

Thank you!

0

Why is the last end underlined?

0

There was one more issue i missed, i forgot to add function

0

now it says "expected ')' to close '(' at column 58, got '('

0

Are you using the first or second one?

0

The second one.

0

Interesting! You may not be able to use FindFirstChild as a parameter, try what ive just editted.

0

FindFirstChild is underlined in blue.

This discussion is preserved as it was. New answers, comments, and votes are closed.