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

Is it possible to change a bool value from a server script parented to a part?

Here is my code for the part:

local orgPos = script.Parent.CFrame
local InRound = game.ReplicatedStorage.InRound
local BlueTake = game.ReplicatedStorage.Bluetake --Here is the bool value I'm trying to change
local debounce = false


function onTouch(hit)
	if not debounce then
		debounce = true
		print(hit.Parent)
		local plr = game.Players:FindFirstChild(hit.Parent.Name)
		local blue = game:GetService("Teams")["Bloo"]
	
		if plr and plr.Team == blue then
			script.Parent.CFrame = game.Workspace.Dump.CFrame
			plr:FindFirstChild("leaderstats")
			wait(1)
			plr.leaderstats.Flags.Value += 1
			print("true")
		end
		if InRound.Value then
			print("checked")
			BlueTake.Value = true --Here's what I did
		end	
		debounce = false
	end
end

script.Parent.Touched:Connect(onTouch)	

InRound.Changed:Connect(function()
	if not InRound.Value then
		script.Parent.CFrame = orgPos
	end
end)

Edit: Sorry if I wasn't clear, I'm posting this question because the script didn't change the value and I don't know why.

1 answer

✓ Accepted answer

Of course. a script can adjust everything everywhere. except things in the local client :)

part.Touched:Connect(function(x1)
if x1.Parent.Humanoid then BlueTake.Value = true end
end)

Thats all.

Oh also, almost forgot, you can use _G to make strings visible across all the scripts. script1

_G.x1 = 'string'

script2:

print(_G.x1)

Output:

'string'

11 comments

0

But it didn't work, it didn't adjust anything.

0

It is supposed to. you messed up something. show me the whole script

0

That is the whole script, there's a boolvalue named Bluetake in Replicatedstorage and I'm trying to get the script to change that value to true if someone touches the part and the round isn't over.

0

I can make you a script to change the boolean but you have to make the round thing ok?

0

Thanks, and yes the round thing has already been made and it is working fine, but the boolean isn't changing.

0

Let me write a script.

0

You also should manage the round with a boolean either. if the round ends the boolean change to false or true idk and all the scripts can see if it ended. it would be easier to do so.

0

Yes that's how I manage the round, with the InRound boolean

0

then add a line: if InRound.Value == false then and add an end before the end) at the end. i hate you so much english.

0

wow, WOW, it worked, why did I not think of this before. Thank you so much.

0

You're welcome.

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