Alright. So, as the title states this will be a really long script I need help on. There are actually 2 scripts but one is much bigger. I have an update bar that displays random text messages, and it works. When the soccer ball hits the detector in the goal, the bar is supposed to show that a goal was made. So far only the random text messages work, but then I also want the ball to go to the middle of the field, which I used cframe for. This is the part that doesnt work. No errors pop up(at least in studio and studio server testing). This is the LocalScript within the update bar(I know its messy code but bare with me here lol):

math.randomseed(tick())
local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui
local bar = playerGui:WaitForChild("Bar")
local redDetector = workspace.RedDetector
local blueDetector = workspace.BlueDetector
local remote = game.ReplicatedStorage.RemoteEvent
canTouch = true

local RandomSentences = {"How's everyone?",
	"Make sure to leave a like ????",
	"This is the update bar!",
	"The easiest way to make a goal is with teamwork!?",
	"Make sure you have defense!",
	"Buy a VIP server to play with only your friends!?????",
	"Gamepasses make the game alot more fun!",
	"The game is always being updated!?"
}

while true do
	wait()
	
	
	--------------------------------------------------------------------------------------
	redDetector.Touched:Connect(function(hit)
		if hit.Name == "Ball" then
			print("hiyo")
			if canTouch == true then
				print("CANTOUCH IS TRUE, RETURNING FALSE")
				canTouch = false
		bar.TextLabel.Text = "The Blue Blueberries just made a goal! Congratulations!"
		
		if canTouch == false then
		remote:FireServer()
		end
		
			
			
		if bar.TextLabel.Text ~= "The Blue Blueberries just made a goal! Congratulations!" then
			bar.TextLabel.Text = "The Blue Blueberries just made a goal! Congratulations!"
		end
		end
		
					
wait(2)
	if bar.TextLabel.Text ~= "The Blue Blueberries just made a goal! Congratulations!" then
			bar.TextLabel.Text = "The Blue Blueberries just made a goal! Congratulations!"
		end
	canTouch = true
	end
	end)
	---------------------------------------------------------------------------
	
	
	
  blueDetector.Touched:Connect(function(hit)
		if hit.Name == "Ball" then
			print("hiyordfs")
			if canTouch == true then
				print("CANTOUCH IS GOING TO FALSE")
				canTouch = false
						bar.TextLabel.Text = "The Red Raspberries just made a goal! Congratulations!"

		
		if canTouch == false then
	remote:FireServer()
	end
	canTouch = true
			end
			
		if bar.TextLabel.Text ~= "The Red Raspberries just made a goal! Congratulations!" then
			bar.TextLabel.Text = "The Red Raspberries just made a goal! Congratulations!"
		end
		end
		
		wait(2)
	if bar.TextLabel.Text ~= "The Blue Blueberries just made a goal! Congratulations!" then
			bar.TextLabel.Text = "The Blue Blueberries just made a goal! Congratulations!"
	end
end)




		------------------------------------------
bar.TextLabel.Text = RandomSentences[math.random(1,8)]
	
	wait(30)
end

Oh, also I used a remote event located in the replicated storage. I figured changing a part location couldnt be done from the client side, which means I must have a server script, which i do. This is the server script, which handles the part cframe. the first lines are cloning the ball in the server storage which from there on will be used until the server dies. Have a look:

local ball = game.ServerStorage.Ball
local newBall = ball:Clone()
newBall.Parent = workspace
newBall.Name = "Ball"
newBall.CFrame = workspace.SpawnPos.CFrame
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local CurrentBall = newBall
remote.OnServerEvent:Connect(function()
	print("server called")
	
	wait(3) --to not instantly move the ball
newBall.CFrame = workspace.SpawnPos.CFrame
		


end)

In conclusion, the bar stating that a goal was made is not working, the cframe for the ball is not working, and none of the prints are working. I am confused, theres no errors or anything of that sort.

I know this is a really perplex question(or maybe not for some of you), so feel free to ask anything and I will try my best to answer. Please remember i am kind of new to scripting. Thanks.

4 comments

0

BTW, the server script is in the SSS

0

What is SSS? Also in your first scriptX you shouldn't put events inside while loops.

0

ServerScriptService probably

0

yeah, serverscriptservice. Any solutions?