Heres an interesting one. I'm trying to make a script that will make it say "Happy Birthday" on the screen. I tried to make it tween to the middle of the screen, but when I run it literally nothing pops up.
Server Script:
--[[ This is a happy birthday script for a friend. Its free of viruses. Scripted by FrostedFlakes67 c: --]] print("Birthday script by FrostedFlakes67 loaded.") --A little credit-- local Credit = script.Parent.Credit game.Players.PlayerAdded:Connect(function(plr) local Clone = Credit:Clone() Clone.Parent = plr.PlayerGui end) --GUI-- local HostName = "FrostedFlakes67" game.Players.PlayerAdded:Connect(function(plr) if plr.Name == HostName then print("Host Joined!") plr.Chatted:Connect(function(msg) print("Host chatted: "..msg) local msglower = string.lower(msg) print("Lowercase versision: "..msglower) if msglower == "happy birthday, alexis!" then warn("Starting!") script.Parent.Start:FireAllClients() end end) end end) --Local Script-- script.Parent.Tweening.Parent = game.StarterPlayer.StarterPlayerScripts
Local script:
--[[ Some tweening c: Scripted by FrostedFlakes67 ]] game.Workspace["Happy birthday!"].Start.OnClientEvent:Connect(function() print(game.Players.LocalPlayer.Name.." recieved the message!") local Text = game.Workspace["Happy birthday!"]["Happy Birthday"].TextLabel print("Text found, starting tweening.") Text:TweenPosition( UDim2.new(0.5,0,0.5,0), Enum.EasingDirection.In, Enum.EasingStyle.Quart, 1 ) print("Tweening finished! Script ending.") end)
Please tell me if I did something wrong. (This time, I'm getting output from everything in both scripts. It says it finished, even though nothing happened.)
well there's a problem, although when designing GUIs in Roblox studio they appear under StarterGui
, when you run the game, the GUIs are actually cloned to the PlayerGui
of each player that joins. all visible GUI's that are in the PlayerGui
of a player will be visible on their screen. however, the text label that you want to tween is in workspace, as indicated that this line of code: local Text = game.Workspace["Happy birthday!"]["Happy Birthday"].TextLabel
.. also make sure things that are accessed by both Server Scripts, and LocalScripts are place in the ReplicatedStorage
.. with that said, here's how i'd write the code.
Server side:
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage"); local tweenInitializer = ReplicatedStorage.Start -- the remote event local host = "FrostedFlakes67" --host's name Players.PlayerAdded:Connect(function(player) if(player.Name == host) then print("The Host joined.."); player.Chatted:Connect(OnHostChatted) end end) function OnHostChatted(msg) print("The Host has chatted"); if(msg:lower() == "happy birthday, alexis!" then tweenInitializer:FireAllClients(); end end
LocalScript
also make sure the GUI that tweens is in the StarterGui
b/c remember, all guis in the StarterGui are cloned in the player's PlayerGUI once they join.. once you make sure its the StarterGui then put a LocalScript in the GUI that tweens and write the following in it..
local ReplicatedStorage = game:GetService("ReplicatedStorage"); local tweenInitializer = ReplicatedStorage.Start -- the remote event tweenInitializer.OnClientEvent:Connect(function() local endPosition = udim2.new(.5,0,.5,0) script.Parent:TweenPosition( endPosition, -- Final position the tween should reach Enum.EasingDirection.Out, -- Direction of the easing Enum.EasingStyle.Quad, -- Kind of easing to apply 2, -- Duration of the tween in seconds true -- Whether in-progress tweens are interrupted ) end)
this show work... test it and see is there's any errors.. also make sure the GUI that tweens is visible